MDL-69688 phpunit: Improve test_context_not_used
This adds a few changes to the old test_context_not_used test: - Move it to become an advanced_test, because its mission is to verify that the assertEventContextNotUsed() assertion works as expected. - For consistency, also move the fixtures to own phpunit fixtures. - Add proper coverage tags, to verify that the assertion is being covered. - Add a data provider to provide all the current cases and ease any future case that may be needed in the future. One by one because previously there was code never executed with the warning expectation causing the test to stop. - Run them in isolation, while this is not strictly required, it's including external fixtures and, we'll need that isolation soon (for changes coming when moving the test to PHPUnit 9.6 in MDL-81266).
This commit is contained in:
@@ -399,7 +399,8 @@ abstract class advanced_testcase extends base_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that an event is not using event->contxet.
|
||||
* Assert that various event methods are not using event->context
|
||||
*
|
||||
* While restoring context might not be valid and it should not be used by event url
|
||||
* or description methods.
|
||||
*
|
||||
@@ -419,7 +420,7 @@ abstract class advanced_testcase extends base_testcase {
|
||||
$event->get_url();
|
||||
$event->get_description();
|
||||
|
||||
// Restore event->context.
|
||||
// Restore event->context (note that this is unreachable when the event uses context). But ok for correct events.
|
||||
phpunit_event_mock::testable_set_event_context($event, $eventcontext);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user