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

    • MOODLE_31_STABLE, MOODLE_32_STABLE

      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")
              );
       
          }
      

            rajeshtaneja Rajesh Taneja
            brudinie guy thomas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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