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

Verify test_invalid_related / test_create_competency_with_nasty_data tests

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.10, 4.0
    • Fix Version/s: None
    • Component/s: Unit tests
    • Labels:
      None
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_400_STABLE

      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

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: