Details
-
Bug
-
Resolution: Fixed
-
Minor
-
3.10, 4.0
-
MOODLE_310_STABLE, MOODLE_400_STABLE
-
MOODLE_310_STABLE, MOODLE_311_STABLE
-
MDL-69700-311 -
Description
These were discovered working on MDL-67673 (upgrade to PHPUnit 8.x). Note this is highly similar to MDL-69688 (happening in another place).
A) test_invalid_related
The test_invalid_related() unit test throws the coding exception when instantiating the core_testable_exporter:
2) core_exporter_testcase::test_invalid_related
|
coding_exception: Coding error detected, it must be fixed by a programmer: Exporter class is missing required related data: (core_testable_exporter) simplestdClass => stdClass
|
|
/home/travis/build/stronk7/moodle/lib/classes/external/exporter.php:106
|
/home/travis/build/stronk7/moodle/lib/tests/exporter_test.php:112
|
/home/travis/build/stronk7/moodle/lib/phpunit/classes/advanced_testcase.php:80
|
|
To re-run:
|
vendor/bin/phpunit --verbose "core_exporter_testcase" lib/tests/exporter_test.php
|
Still the unit test has more code following and that's misleading because that code is never executed.
This issue is about to decide if the exception is being thrown in correct place and the trailing code can be removed... of if the test is bogus and the exception should happen later.
To reproduce it:
1. Edit lib/tests/exporter_test.php
2. Go to test_invalid_related()
3. Comment out the $this->expectException(coding_exception::class); line
4. Run $ vendor/bin/phpunit --filter ::test_invalid_related
5. See where the exception happens and analyse what happens with the trailing code in the method.
B) test_create_competency_with_nasty_data
Exactly the same case than the above one, the exception happens when the competency is created, and there is trailing code, never executed. Decide if the exception is happening in correct place and the trailing code can be safely removed.
To reproduce, similar to the reproduction steps above... comment the $this->expectException line and run the test ($ vendor/bin/phpunit --filter ::test_create_competency_with_nasty_data).
Attachments
Issue Links
- Discovered while testing
-
MDL-71036 Upgrade PHPUnit to 9.5.x
-
- Closed
-
-
MDL-67673 Upgrade phpunit to 8.5.x
-
- Closed
-
- has been marked as being related by
-
MDL-69688 Verify test_context_not_used unit test and fix it
-
- Open
-
- will help resolve
-
MDL-73227 Fix incorrect/misleading usage of expectException in unit tests
-
- Open
-