[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/choice/tests/behat/ -> behat_mod_choice.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   * Steps definitions for choice activity.
  19   *
  20   * @package   mod_choice
  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   * Choice activity definitions.
  34   *
  35   * @package   mod_choice
  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_mod_choice extends behat_base {
  41  
  42      /**
  43       * Chooses the specified option from the choice activity named as specified. You should be located in the activity's course page.
  44       *
  45       * @Given /^I choose "(?P<option_string>(?:[^"]|\\")*)" from "(?P<choice_activity_string>(?:[^"]|\\")*)" choice activity$/
  46       * @param string $option
  47       * @param string $choiceactivity
  48       * @return array
  49       */
  50      public function I_choose_option_from_activity($option, $choiceactivity) {
  51  
  52          // Escaping again the strings as backslashes have been removed by the automatic transformation.
  53          return array(
  54              new Given('I follow "' . $this->escape($choiceactivity) . '"'),
  55              new Given('I set the field "' . $this->escape($option) . '" to "1"'),
  56              new Given('I press "' . get_string('savemychoice', 'choice') . '"')
  57          );
  58      }
  59  
  60      /**
  61       * Chooses the specified option from the choice activity named as specified and save the choice.
  62       * You should be located in the activity's course page.
  63       *
  64       * @Given /^I choose options (?P<option_string>"(?:[^"]|\\")*"(?:,"(?:[^"]|\\")*")*) from "(?P<choice_activity_string>(?:[^"]|\\")*)" choice activity$/
  65       * @param string $option
  66       * @param string $choiceactivity
  67       * @return array
  68       */
  69      public function I_choose_options_from_activity($option, $choiceactivity) {
  70          // Escaping again the strings as backslashes have been removed by the automatic transformation.
  71          $return = array(new Given('I follow "' . $this->escape($choiceactivity) . '"'));
  72          $options = explode('","', trim($option, '"'));
  73          foreach ($options as $option) {
  74              $return[] = new Given('I set the field "' . $this->escape($option) . '" to "1"');
  75          }
  76          $return[] = new Given('I press "' . get_string('savemychoice', 'choice') . '"');
  77          return $return;
  78      }
  79  
  80  }


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