-
Bug
-
Resolution: Fixed
-
Minor
-
3.10
This was discovered working on MDL-67673 (upgrade to PHPUnit 8.x). Note this is highly similar to MDL-69700 (happening in another place).
The test_context_not_used() unit test is really strange, but that's normally not detected because the test expects a notice and certainly gets it.
To reproduce it:
1) Edit lib/tests/event_test.php, go to the test_context_not_used() method and comment the line:
$this->expectException(\PHPUnit\Framework\Error\Notice::class);
|
2) Run $ vendor/bin/phpunit --filter ::test_context_not_used
3 You will get:
There was 1 error:
|
|
1) core_event_testcase::test_context_not_used
|
Trying to get property 'instanceid' of non-object
|
The points here are:
a) Verify that really that's the notice the test is expecting, because it's a really strange one. Fix it if that's not the case.
b) Move the exception expectation to the correct place. Note that right now the notice happens in the 1st line after the expectation and that's strange because then... what's all the remaining code about? It's not reachable (the exception happens earlier).
And that's it. As said, the problem is masked because the test expects a notice/warning. This is just about to ensure that's the notice it is expecting and that there isn't trailing code after the notice happens.
- blocks
-
MDL-81266 Bump behat and phpunit (composer) to current ones (PHP 8.3 / Moodle 4.4)
- Closed
- Discovered while testing
-
MDL-71036 Upgrade PHPUnit to 9.5.x
- Closed
-
MDL-67673 Upgrade phpunit to 8.5.x
- Closed
- has a non-specific relationship to
-
MDL-43736 Event should use event->contextinstanceid and not event->context->instanceid
- Closed
-
MDL-69700 Verify test_invalid_related / test_create_competency_with_nasty_data tests
- Closed
- has been marked as being related by
-
MDL-81281 PHPUnit 9.6: replace assertions that operate on class/object properties
- Closed