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

Behat - course completion test for activity marked as complete broken with multiple activities of same type

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE

      Description

      Pre-requisites -

      Behat test turns on auto completion.

      Description of issue -

      If you have multiple activities of the same type generated by a behat test and you want to find out the completion state of both it will fail by only looking at the first one.

      This is because it is using the "behat_general::should_exist_in_the" function to check in one single element. It hit's the first element of a specific type and then ignores subsequent elements of the same type.

      The code is in completion/tests/behat/behat_completion.php

          /**
           * Checks if the activity with specified name is maked as complete.
           *
           * @Given /^the "(?P<activityname_string>(?:[^"]|\\")*)" "(?P<activitytype_string>(?:[^"]|\\")*)" activity with "(manual|auto)" completion should be marked as complete$/
           */
          public function activity_marked_as_complete($activityname, $activitytype, $completiontype) {
              if ($completiontype == "manual") {
                  $imgalttext = get_string("completion-alt-manual-y", 'core_completion', $activityname);
              } else {
                  $imgalttext = get_string("completion-alt-auto-y", 'core_completion', $activityname);
              }
              $csselementforactivitytype = "li.modtype_".strtolower($activitytype);
       
              $xpathtocheck = "//img[contains(@alt, '$imgalttext')]";
              $this->execute("behat_general::should_exist_in_the",
                  array($xpathtocheck, "xpath_element", $csselementforactivitytype, "css_element")
              );
       
          }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rajeshtaneja Rajesh Taneja
              Reporter:
              brudinie guy thomas
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: