Skip to content

Commit

Permalink
Merge branch 'MDL-76399-311' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_311_STABLE
  • Loading branch information
ilyatregubov committed Dec 29, 2022
2 parents 9da4095 + e59e39c commit 48256e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
3 changes: 1 addition & 2 deletions lib/behat/classes/behat_session_trait.php
Expand Up @@ -440,13 +440,12 @@ protected function get_node_in_container($selectortype, $element, $containersele
if ($containerselectortype === 'NodeElement' && is_a($containerelement, NodeElement::class)) {
// Support a NodeElement being passed in for use in step chaining.
$containernode = $containerelement;
$locatorexceptionmsg = $element;
} else {
// Gets the container, it will always be text based.
$containernode = $this->get_text_selector_node($containerselectortype, $containerelement);
$locatorexceptionmsg = $element . '" in the "' . $containerelement. '" "' . $containerselectortype. '"';
}

$locatorexceptionmsg = $element . '" in the "' . $this->get_selector_description($containerselectortype, $containerelement);
$exception = new ElementNotFoundException($this->getSession(), $selectortype, null, $locatorexceptionmsg);

return $this->find($selectortype, $element, $exception, $containernode);
Expand Down
21 changes: 7 additions & 14 deletions lib/tests/behat/behat_general.php
Expand Up @@ -28,6 +28,7 @@
require_once(__DIR__ . '/../../behat/behat_base.php');

use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Mink\Exception\ExpectationException;
Expand Down Expand Up @@ -1162,20 +1163,12 @@ public function i_run_all_adhoc_tasks() {
* @throws ElementNotFoundException Thrown by behat_base::find
* @param string $element The locator of the specified selector
* @param string $selectortype The selector type
* @param string $containerelement The container selector type
* @param string $containerselectortype The container locator
* @param NodeElement|string $containerelement The locator of the container selector
* @param string $containerselectortype The container selector type
*/
public function should_exist_in_the($element, $selectortype, $containerelement, $containerselectortype) {
// Get the container node.
$containernode = $this->find($containerselectortype, $containerelement);

// Specific exception giving info about where can't we find the element.
$containerdescription = $this->get_selector_description($containerselectortype, $containerelement);
$locatorexceptionmsg = "{$element} not found in the {$containerdescription}}";
$exception = new ElementNotFoundException($this->getSession(), $selectortype, null, $locatorexceptionmsg);

// Looks for the requested node inside the container node.
$this->find($selectortype, $element, $exception, $containernode);
// Will throw an ElementNotFoundException if it does not exist.
$this->get_node_in_container($selectortype, $element, $containerselectortype, $containerelement);
}

/**
Expand All @@ -1187,8 +1180,8 @@ public function should_exist_in_the($element, $selectortype, $containerelement,
* @throws ExpectationException
* @param string $element The locator of the specified selector
* @param string $selectortype The selector type
* @param string $containerelement The container selector type
* @param string $containerselectortype The container locator
* @param NodeElement|string $containerelement The locator of the container selector
* @param string $containerselectortype The container selector type
*/
public function should_not_exist_in_the($element, $selectortype, $containerelement, $containerselectortype) {
// Get the container node.
Expand Down
2 changes: 1 addition & 1 deletion question/tests/behat/question_categories.feature
Expand Up @@ -34,7 +34,7 @@ Feature: A teacher can put questions in categories in the question bank
And I press "submitbutton"
Then I should see "New Category 1 ID number newcatidnumber (0)"
And I should see "Created as a test" in the "New Category 1" "list_item"
And "New Category 1 [newcatidnumber]" "option" should exist in the "Parent category" "select"
And the "Parent category" select box should contain "New Category 1 [newcatidnumber]"

Scenario: A question category can be edited
When I am on the "Course 1" "core_question > course question categories" page logged in as "teacher1"
Expand Down

0 comments on commit 48256e0

Please sign in to comment.