芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/question/tests/behat/behat_question.php
. /** * Behat question-related steps definitions. * * @package core_question * @category test * @copyright 2013 David Monllaó * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. require_once(__DIR__ . '/behat_question_base.php'); use Behat\Gherkin\Node\TableNode as TableNode, Behat\Mink\Exception\ExpectationException as ExpectationException, Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException; /** * Steps definitions related with the question bank management. * * @package core_question * @category test * @copyright 2013 David Monllaó * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class behat_question extends behat_question_base { /** * Creates a question in the current course questions bank with the provided data. This step can only be used when creating question types composed by a single form. * * @Given /^I add a "(?P
(?:[^"]|\\")*)" question filling the form with:$/ * @param string $questiontypename The question type name * @param TableNode $questiondata The data to fill the question type form. */ public function i_add_a_question_filling_the_form_with($questiontypename, TableNode $questiondata) { // Go to question bank. $this->execute("behat_general::click_link", get_string('questionbank', 'question')); // Click on create question. $this->execute('behat_forms::press_button', get_string('createnewquestion', 'question')); // Add question. $this->finish_adding_question($questiontypename, $questiondata); } /** * Checks the state of the specified question. * * @Then /^the state of "(?P
(?:[^"]|\\")*)" question is shown as "(?P
(?:[^"]|\\")*)"$/ * @throws ExpectationException * @throws ElementNotFoundException * @param string $questiondescription * @param string $state */ public function the_state_of_question_is_shown_as($questiondescription, $state) { // Using xpath literal to avoid quotes problems. $questiondescriptionliteral = behat_context_helper::escape($questiondescription); $stateliteral = behat_context_helper::escape($state); // Split in two checkings to give more feedback in case of exception. $exception = new ElementNotFoundException($this->getSession(), 'Question "' . $questiondescription . '" '); $questionxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' que ')]" . "[contains(div[@class='content']/div[contains(concat(' ', normalize-space(@class), ' '), ' formulation ')]," . "{$questiondescriptionliteral})]"; $this->find('xpath', $questionxpath, $exception); $exception = new ExpectationException('Question "' . $questiondescription . '" state is not "' . $state . '"', $this->getSession()); $xpath = $questionxpath . "/div[@class='info']/div[@class='state' and contains(., {$stateliteral})]"; $this->find('xpath', $xpath, $exception); } /** * Activates a particular action on a particular question in the question bank UI. * * @When I choose :action action for :questionname in the question bank * @param string $action the label for the action you want to activate. * @param string $questionname the question name. */ public function i_action_the_question($action, $questionname) { if ($action == 'Edit question') { $action = 'Edit'; } // Click the action from the menu. $this->execute("behat_general::i_click_on_in_the", [$action, 'link', $questionname, 'table_row']); } }