Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-69700

Verify test_invalid_related / test_create_competency_with_nasty_data tests

XMLWordPrintable

      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).

            pholden Paul Holden
            stronk7 Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 21 minutes
                1h 21m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.