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

Update phpunit tests files where multiple test classes are defined

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.11
    • 2.3.4, 2.4, 2.4.1
    • Unit tests
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_311_STABLE
    • Hide

      Before the patch

      1. Run this command in the root of moodle directory:
        find . -name "*_test.php" | xargs grep -Pc "^ *class .*test(case)? " | grep -v :1
      2. Verify that it returns these 4 results:

        ./admin/tool/httpsreplace/tests/httpsreplace_test.php:2
        ./files/tests/converter_test.php:4
        ./grade/tests/reportlib_test.php:2
        ./lib/tests/portfoliolib_test.php:2
        

      After the patch

      1. Prepare phpunit. Run:
        php admin/tool/phpunit/cli/init.php
      2. Run the following unit tests and check the results:
        1. vendor/bin/phpunit admin/tool/httpsreplace/tests/httpsreplace_test.php
        2. Verify that you get: OK (26 tests, 57 assertions)
        3. vendor/bin/phpunit files/tests/converter_test.php
        4. Verify that you get: OK (27 tests, 34 assertions)
        5. vendor/bin/phpunit grade/tests/reportlib_test.php
        6. Verify that you get: OK (1 test, 6 assertions)
        7. vendor/bin/phpunit lib/tests/portfoliolib_test.php
        8. Verify that you get: OK (1 test, 13 assertions)
      3. Run this command in the root of moodle directory:
        find . -name "*_test.php" | xargs grep -Pc "^ *class .*test(case)? " | grep -v :1
      4. Verify that it returns no results now (was returning them before the patch).
      Show
      Before the patch Run this command in the root of moodle directory: find . -name "*_test.php" | xargs grep -Pc "^ *class .*test(case)? " | grep -v :1 Verify that it returns these 4 results: ./admin/tool/httpsreplace/tests/httpsreplace_test.php:2 ./files/tests/converter_test.php:4 ./grade/tests/reportlib_test.php:2 ./lib/tests/portfoliolib_test.php:2 After the patch Prepare phpunit. Run: php admin/tool/phpunit/cli/init.php Run the following unit tests and check the results: vendor/bin/phpunit admin/tool/httpsreplace/tests/httpsreplace_test.php Verify that you get: OK (26 tests, 57 assertions) vendor/bin/phpunit files/tests/converter_test.php Verify that you get: OK (27 tests, 34 assertions) vendor/bin/phpunit grade/tests/reportlib_test.php Verify that you get: OK (1 test, 6 assertions) vendor/bin/phpunit lib/tests/portfoliolib_test.php Verify that you get: OK (1 test, 13 assertions) Run this command in the root of moodle directory: find . -name "*_test.php" | xargs grep -Pc "^ *class .*test(case)? " | grep -v :1 Verify that it returns no results now (was returning them before the patch).

      Refer https://moodle.org/local/chatlogs/index.php?conversationid=11971#c409213

      We are not allowed to have more than one test class per file.
      We are doing this at lib/tests/outputcomponents_tests.php and probabily few other places.
      Such tests are simply ignored with no msg and warning any where.

            stronk7 Eloy Lafuente (stronk7)
            ankit_frenz Ankit Agarwal
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Adrian Greeve Adrian Greeve
            Gladys Basiana Gladys Basiana
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 5 minutes
                3h 5m

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