[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/data/tests/behat/ -> behat_mod_data.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 related with the database activity.
  19   *
  20   * @package    mod_data
  21   * @category   test
  22   * @copyright  2014 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      Behat\Behat\Context\Step\When as When,
  32      Behat\Gherkin\Node\TableNode as TableNode;
  33  /**
  34   * Database-related steps definitions.
  35   *
  36   * @package    mod_data
  37   * @category   test
  38   * @copyright  2014 David Monllaó
  39   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  40   */
  41  class behat_mod_data extends behat_base {
  42  
  43      /**
  44       * Adds a new field to a database
  45       *
  46       * @Given /^I add a "(?P<fieldtype_string>(?:[^"]|\\")*)" field to "(?P<activityname_string>(?:[^"]|\\")*)" database and I fill the form with:$/
  47       *
  48       * @param string $fieldtype
  49       * @param string $activityname
  50       * @param TableNode $fielddata
  51       * @return Given[]
  52       */
  53      public function i_add_a_field_to_database_and_i_fill_the_form_with($fieldtype, $activityname, TableNode $fielddata) {
  54  
  55          $steps = array(
  56              new Given('I follow "' . $this->escape($activityname) . '"'),
  57              new Given('I follow "' . get_string('fields', 'mod_data') . '"'),
  58              new Given('I set the field "newtype" to "' . $this->escape($fieldtype) . '"')
  59          );
  60  
  61          if (!$this->running_javascript()) {
  62              $steps[] = new Given('I click on "' . get_string('go') . '" "button" in the ".fieldadd" "css_element"');
  63          }
  64  
  65          array_push(
  66              $steps,
  67              new Given('I set the following fields to these values:', $fielddata),
  68              new Given('I press "' . get_string('add') . '"')
  69          );
  70  
  71          return $steps;
  72      }
  73  
  74      /**
  75       * Adds an entry to a database.
  76       *
  77       * @Given /^I add an entry to "(?P<activityname_string>(?:[^"]|\\")*)" database with:$/
  78       *
  79       * @param string $activityname
  80       * @param TableNode $entrydata
  81       * @return When[]
  82       */
  83      public function i_add_an_entry_to_database_with($activityname, TableNode $entrydata) {
  84  
  85          return array(
  86              new When('I follow "' . $this->escape($activityname) . '"'),
  87              new When('I follow "' . get_string('add', 'mod_data') . '"'),
  88              new When('I set the following fields to these values:', $entrydata),
  89          );
  90      }
  91  }


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