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

Fix qtype_ordering\questiontype_test::test_gift_export unit test (windows)

XMLWordPrintable

    • MOODLE_404_STABLE, MOODLE_405_STABLE
    • MOODLE_404_STABLE
    • MDL-81581_404
    • Hide
      • Init PHPUnit normally (php admin/tool/phpunit/cli/init.php).
      • Create all the distributed phpunit.xml files (php admin/tool/phpunit/cli/util.php --buildcomponentconfigs).
      • Verify that a PHPUnit execution of the tests in the "question" directory pass without problems (vendor/bin/phpunit -c question), both with:
        • unix (linux or mac) and
        • windows.
      • Verify that there aren't remaining tests using str_replace('\r\n', ...) by running this command in Moodle's dir root:

        grep -r 'str_replace.*\\r\\n' * | grep '_test.php'

      Show
      Init PHPUnit normally ( php admin/tool/phpunit/cli/init.php ). Create all the distributed phpunit.xml files ( php admin/tool/phpunit/cli/util.php --buildcomponentconfigs ). Verify that a PHPUnit execution of the tests in the "question" directory pass without problems ( vendor/bin/phpunit -c question ), both with: unix (linux or mac) and windows. Verify that there aren't remaining tests using str_replace('\r\n', ...) by running this command in Moodle's dir root: grep -r 'str_replace.*\\r\\n' * | grep '_test.php'

      This is a regression introduced by MDL-80416 and causing one consistent unit test failure under windows:

      3) qtype_ordering\questiontype_test::test_gift_export
      Failed asserting that two strings are equal.
      --- Expected
      +++ Actual
      @@ @@
       '// question: 123  name: Moodle\n
       // [id:myid]\n
      -::Moodle::[html]Put these words in order.{>2     none\n
      -Modular\n
      -Object\n
      -Oriented\n
      -Dynamic\n
      -Learning\n
      -Environment\n
      +::Moodle::[html]Put these words in order.{>2     none\r\n
      +Modular\r\n
      +Object\r\n
      +Oriented\r\n
      +Dynamic\r\n
      +Learning\r\n
      +Environment\r\n
       }\n
       '
       
      C:\Users\stronk7\git_moodle\integration\question\type\ordering\tests\questiontype_test.php:329
      C:\Users\stronk7\git_moodle\integration\lib\phpunit\classes\advanced_testcase.php:72
      

      From the previous discussion in the original issue, this should be the plan to fix the EOL problems (quoting Tim):

      If you look at the tests of Moodle XML import/export, then they use a method assert_same_xml which compares two strings while ignoring line endings.

      We could do something similar here. (But, don't use a method called assert_same_xml to compare GIFT format. That is confusing. Make a new assert_same_text_ingoring_line_endings - and use that in your test, and refactor assert_same_xml to use it.

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Angelia Dela Cruz Angelia Dela Cruz
            Simey Lameze Simey Lameze
            Glyn (Mathew) May Glyn (Mathew) May
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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