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

Bad code in many 'should not' rules in behat_general.php

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      This really needs to be tested together with MDL-49445

      1. Pull the latest MDL-40990 code.
      2. Edit mod/quiz/tests/behat/editing_require_previous.feature, the scenario "Question dependency cannot apply to quizzes where the questions are shuffled so UI is hidden" that starts around like 120
      3. Change shufflequestions to 0, so the test should fail.
      4. Run that senario, and verify that Behat reports the failure

      (Until I had fixed this, and #MDL-49445, it would not fail.)

      Show
      This really needs to be tested together with MDL-49445 Pull the latest MDL-40990 code. Edit mod/quiz/tests/behat/editing_require_previous.feature, the scenario "Question dependency cannot apply to quizzes where the questions are shuffled so UI is hidden" that starts around like 120 Change shufflequestions to 0, so the test should fail. Run that senario, and verify that Behat reports the failure (Until I had fixed this, and # MDL-49445 , it would not fail.)
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      There is lots of code like

              try {
                  $this->row_column_of_table_should_contain($row, $column, $table, $value);
                  // Throw exception if found.
                  throw new ExpectationException(
                      '"' . $column . '" with value "' . $value . '" is present in "' . $row . '"  row for table "' . $table . '"',
                      $this->getSession()
                  );
              } catch (ElementNotFoundException $e) {
                  // Table row/column doesn't contain this value. Nothing to do.
                  return;
              }
      

      This does not work as intended, because the thrown exceptoin is immediately caught again.

      Actually, that one is OK, since the two exceptoin types are different, but other ones were wrong, and the pattern is dangerous, in case anyone changes the exception types in future. I will fix them all, even the ones that are not broken.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              timhunt Tim Hunt
              Peer reviewer:
              Rajesh Taneja
              Integrator:
              David Monllaó
              Tester:
              Adrian Greeve
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/15