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

Update phpunit tests files where multiple test classes are defined

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4, 2.4, 2.4.1
    • Fix Version/s: 3.11
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      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).
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull 3.11 Branch:
      MDL-37655_311
    • Pull Master Branch:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              ankit_frenz Ankit Agarwal
              Peer reviewer:
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Integrator:
              Adrian Greeve Adrian Greeve
              Tester:
              Gladys Basiana Gladys Basiana
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/21

                  Time Tracking

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