[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/cohort/tests/behat/ -> behat_cohort.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Cohorts steps definitions.
  19   *
  20   * @package    core_cohort
  21   * @category   test
  22   * @copyright  2013 David Monllaó
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
  27  
  28  require_once (__DIR__ . '/../../../lib/behat/behat_base.php');
  29  
  30  use Behat\Behat\Context\Step\Given as Given;
  31  
  32  /**
  33   * Steps definitions for cohort actions.
  34   *
  35   * @package    core_cohort
  36   * @category   test
  37   * @copyright  2013 David Monllaó
  38   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  class behat_cohort extends behat_base {
  41  
  42      /**
  43       * Adds the user to the specified cohort. The user should be specified like "Firstname Lastname ([email protected])".
  44       *
  45       * @Given /^I add "(?P<user_fullname_string>(?:[^"]|\\")*)" user to "(?P<cohort_idnumber_string>(?:[^"]|\\")*)" cohort members$/
  46       * @param string $user
  47       * @param string $cohortidnumber
  48       */
  49      public function i_add_user_to_cohort_members($user, $cohortidnumber) {
  50  
  51          $steps = array(
  52              new Given('I click on "' . get_string('assign', 'cohort') . '" "link" in the "' . $this->escape($cohortidnumber) . '" "table_row"'),
  53              new Given('I set the field "' . get_string('potusers', 'cohort') . '" to "' . $this->escape($user) . '"'),
  54              new Given('I press "' . get_string('add') . '"'),
  55              new Given('I press "' . get_string('backtocohorts', 'cohort') . '"')
  56          );
  57  
  58          // If we are not in the cohorts management we should move there before anything else.
  59          if (!$this->getSession()->getPage()->find('css', 'input#cohort_search_q')) {
  60  
  61              // With JS enabled we should expand a few tree nodes.
  62              if ($this->running_javascript()) {
  63                  $parentnodes = get_string('administrationsite') . ' > ' .
  64                      get_string('users', 'admin') . ' > ' .
  65                      get_string('accounts', 'admin');
  66                  $steps = array_merge(
  67                      array(
  68                          new Given('I am on homepage'),
  69                          new Given('I navigate to "' . get_string('cohorts', 'cohort') . '" node in "' . $parentnodes . '"')
  70                      ),
  71                      $steps
  72                  );
  73  
  74              } else {
  75                  // JS disabled.
  76                  $steps = array_merge(
  77                      array(
  78                          new Given('I am on homepage'),
  79                          new Given('I follow "' . get_string('administrationsite') . '" node'),
  80                          new Given('I follow "' . get_string('cohorts', 'cohort') . '"')
  81                      ),
  82                      $steps
  83                  );
  84              }
  85          }
  86  
  87          return $steps;
  88      }
  89  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1