Commit 42ad096f authored by Rajesh Taneja's avatar Rajesh Taneja
Browse files

MDL-46891 Behat: Added support for behat 3

parent e8952c59
......@@ -28,8 +28,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/../../../lib/behat/behat_field_manager.php');
use Behat\Behat\Context\Step\Given as Given,
Behat\Gherkin\Node\TableNode as TableNode,
use Behat\Gherkin\Node\TableNode as TableNode,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
/**
......
......@@ -142,11 +142,10 @@ class tool_behat_manager_testcase extends advanced_testcase {
// YAML decides when is is necessary to wrap strings between single quotes, so not controlled
// values like paths should not be asserted including the key name as they would depend on the
// directories values.
$this->assertContains($CFG->dirroot . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'features', $contents);
$this->assertContains($CFG->dirroot, $contents);
// Not quoted strings.
$this->assertContains('micarro: /me/lo/robaron', $contents);
$this->assertContains('class: behat_init_context', $contents);
// YAML uses single quotes to wrap URL strings.
$this->assertContains("base_url: '" . $CFG->behat_wwwroot . "'", $contents);
......
......@@ -13,10 +13,10 @@ Feature: Manage language packs
Scenario: Install language pack
Given I log in as "admin"
And I navigate to "Language packs" node in "Site administration > Language"
When I set the field "Available language packs" to "English - Pirate (en_ar)"
When I set the field "Available language packs" to "en_ar"
And I press "Install selected language pack(s)"
Then I should see "Language pack 'en_ar' was successfully installed"
And the "Installed language packs" select box should contain "English - Pirate (en_ar)"
And the "Installed language packs" select box should contain "en_ar"
And I navigate to "Live logs" node in "Site administration > Reports"
And I should see "The language pack 'en_ar' was installed."
And I log out
......@@ -35,14 +35,14 @@ Feature: Manage language packs
Scenario: Try to uninstall language pack
Given I log in as "admin"
And I navigate to "Language packs" node in "Site administration > Language"
And I set the field "Available language packs" to "English - Pirate (en_ar)"
And I set the field "Available language packs" to "en_ar"
And I press "Install selected language pack(s)"
When I set the field "Installed language packs" to "English - Pirate (en_ar)"
When I set the field "Installed language packs" to "en_ar"
And I press "Uninstall selected language pack(s)"
And I press "Continue"
Then I should see "Language pack 'en_ar' was uninstalled"
And the "Installed language packs" select box should not contain "English - Pirate (en_ar)"
And the "Available language packs" select box should contain "English - Pirate (en_ar)"
And the "Installed language packs" select box should not contain "en_ar"
And the "Available language packs" select box should contain "en_ar"
And I navigate to "Live logs" node in "Site administration > Reports"
And I should see "The language pack 'en_ar' was removed."
And I should see "Language pack uninstalled"
......@@ -51,7 +51,7 @@ Feature: Manage language packs
Scenario: Try to uninstall English language pack
Given I log in as "admin"
And I navigate to "Language packs" node in "Site administration > Language"
When I set the field "Installed language packs" to "English (en)"
When I set the field "Installed language packs" to "en"
And I press "Uninstall selected language pack(s)"
Then I should see "The English language pack cannot be uninstalled."
And I navigate to "Live logs" node in "Site administration > Reports"
......
......@@ -28,8 +28,8 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given;
use Behat\Behat\Context\Step\When as When;
use Moodle\BehatExtension\Context\Step\Given as Given;
use Moodle\BehatExtension\Context\Step\When as When;
/**
* Log in log out steps definitions.
......
......@@ -219,7 +219,6 @@ class behat_backup extends behat_base {
"/descendant::div[@class='restore-course-search']" .
"/descendant::tr[contains(., $existingcourse)]" .
"/descendant::input[@type='radio']");
$radionode->check();
$radionode->click();
// Pressing the continue button of the restore into an existing course section.
......@@ -250,7 +249,6 @@ class behat_backup extends behat_base {
$radionode = $this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), ' bcs-new-course ')]" .
"/descendant::div[@class='restore-course-search']" .
"/descendant::input[@type='radio']");
$radionode->check();
$radionode->click();
// Pressing the continue button of the restore into an existing course section.
......@@ -280,7 +278,6 @@ class behat_backup extends behat_base {
// Merge without deleting radio option.
$radionode = $this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), 'bcs-current-course')]" .
"/descendant::input[@type='radio'][@name='target'][@value='1']");
$radionode->check();
$radionode->click();
// Pressing the continue button of the restore merging section.
......@@ -310,7 +307,6 @@ class behat_backup extends behat_base {
// Delete contents radio option.
$radionode = $this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), 'bcs-current-course')]" .
"/descendant::input[@type='radio'][@name='target'][@value='0']");
$radionode->check();
$radionode->click();
// Pressing the continue button of the restore merging section.
......@@ -419,8 +415,6 @@ class behat_backup extends behat_base {
return;
}
$pageoptions = clone $options;
$rows = $options->getRows();
$newrows = array();
foreach ($rows as $k => $data) {
......@@ -433,7 +427,8 @@ class behat_backup extends behat_base {
$newrows[] = $data;
}
}
$pageoptions->setRows($newrows);
$pageoptions = new TableNode($newrows);
return $pageoptions;
}
......
default:
paths:
features: lib/behat/features
bootstrap: lib/behat/features/bootstrap
context:
class: behat_init_context
suites:
default:
paths: { }
contexts: { }
extensions:
Behat\MinkExtension\Extension:
Behat\MinkExtension:
base_url: 'http://localhost:8000'
goutte: null
selenium2: null
Moodle\BehatExtension\Extension:
features: { }
Moodle\BehatExtension:
moodledirroot: /Should/Change/To/Moodle/www/dir
steps_definitions: { }
......@@ -27,7 +27,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given;
use Moodle\BehatExtension\Context\Step\Given as Given;
/**
* Blocks management steps definitions.
......
......@@ -26,7 +26,7 @@
// NOTE: no MOODLE_INTERNAL used, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given;
use Moodle\BehatExtension\Context\Step\Given as Given;
use Behat\Gherkin\Node\TableNode as TableNode;
/**
......
......@@ -27,7 +27,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given;
use Moodle\BehatExtension\Context\Step\Given as Given;
/**
* Steps definitions for cohort actions.
......
......@@ -27,8 +27,8 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given,
Behat\Behat\Context\Step\Then,
use Moodle\BehatExtension\Context\Step\Given,
Moodle\BehatExtension\Context\Step\Then,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
/**
......
......@@ -683,8 +683,15 @@ $CFG->admin = 'admin';
// )
// ),
// 'Mac-Firefox' => array(
// 'suites' => array (
// 'default' => array(
// 'filters' => array(
// 'tags' => '~@_file_upload'
// ),
// ),
// ),
// 'extensions' => array(
// 'Behat\MinkExtension\Extension' => array(
// 'Behat\MinkExtension' => array(
// 'selenium2' => array(
// 'browser' => 'firefox',
// 'capabilities' => array(
......@@ -697,7 +704,7 @@ $CFG->admin = 'admin';
// ),
// 'Mac-Safari' => array(
// 'extensions' => array(
// 'Behat\MinkExtension\Extension' => array(
// 'Behat\MinkExtension' => array(
// 'selenium2' => array(
// 'browser' => 'safari',
// 'capabilities' => array(
......
......@@ -27,7 +27,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given,
use Moodle\BehatExtension\Context\Step\Given as Given,
Behat\Gherkin\Node\TableNode as TableNode,
Behat\Mink\Exception\ExpectationException as ExpectationException,
Behat\Mink\Exception\DriverException as DriverException,
......@@ -97,7 +97,7 @@ class behat_course extends behat_base {
unset($rows[$key]);
}
}
$table->setRows($rows);
$table = new TableNode($rows);
// Adding a forced wait until editors are loaded as otherwise selenium sometimes tries clicks on the
// format field when the editor is being rendered and the click misses the field coordinates.
......@@ -585,7 +585,7 @@ class behat_course extends behat_base {
// The 'Hide' button should be available.
$nohideexception = new ExpectationException('"' . $activityname . '" don\'t have a "' . get_string('hide') . '" icon', $this->getSession());
$this->find('named', array('link', get_string('hide')), $nohideexception, $activitynode);
$this->find('named_partial', array('link', get_string('hide')), $nohideexception, $activitynode);
}
}
......@@ -611,7 +611,7 @@ class behat_course extends behat_base {
// Also 'Show' icon.
$noshowexception = new ExpectationException('"' . $activityname . '" don\'t have a "' . get_string('show') . '" icon', $this->getSession());
$this->find('named', array('link', get_string('show')), $noshowexception, $activitynode);
$this->find('named_partial', array('link', get_string('show')), $noshowexception, $activitynode);
} else {
......
......@@ -105,7 +105,6 @@ Feature: Test we can resort categories in the management interface.
And I should see the "Course categories and courses" management page
And I click on <sortby> action for "Master cat" in management category listing
And a new page should have loaded since I started watching
And I start watching to see if a new page loads
And I should see the "Course categories and courses" management page
And I should see category listing <cat1> before <cat2>
And I should see category listing <cat2> before <cat3>
......
......@@ -86,7 +86,6 @@ Feature: Test we can resort course in the management interface.
And I should see "Sort by Course time created descending" in the ".course-listing-actions" "css_element"
And I click on <sortby> "link" in the ".course-listing-actions" "css_element"
And a new page should have loaded since I started watching
And I start watching to see if a new page loads
And I should see the "Course categories and courses" management page
And I should see course listing <course1> before <course2>
And I should see course listing <course2> before <course3>
......
......@@ -27,7 +27,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given,
use Moodle\BehatExtension\Context\Step\Given as Given,
Behat\Gherkin\Node\TableNode as TableNode;
/**
......
......@@ -26,9 +26,9 @@
require_once(__DIR__ . '/../../../../../../lib/behat/behat_base.php');
use Behat\Gherkin\Node\TableNode as TableNode,
Behat\Behat\Context\Step\Given as Given,
Behat\Behat\Context\Step\When as When,
Behat\Behat\Context\Step\Then as Then,
Moodle\BehatExtension\Context\Step\Given as Given,
Moodle\BehatExtension\Context\Step\When as When,
Moodle\BehatExtension\Context\Step\Then as Then,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
Behat\Mink\Exception\ExpectationException as ExpectationException;
......
......@@ -28,9 +28,7 @@
require_once(__DIR__ . '/../../../../../../lib/behat/behat_base.php');
use Behat\Gherkin\Node\TableNode as TableNode,
Behat\Behat\Context\Step\Given as Given,
Behat\Behat\Context\Step\When as When,
Behat\Behat\Context\Step\Then as Then,
Moodle\BehatExtension\Context\Step\Given as Given,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
Behat\Mink\Exception\ExpectationException as ExpectationException;
......@@ -107,6 +105,15 @@ class behat_gradingform_rubric extends behat_base {
}
}
// Remove empty criterion, as TableNode might contain them to make table rows equal size.
$newcriterion = array();
foreach ($criterion as $k => $c) {
if (!empty($c)) {
$newcriterion[$k] = $c;
}
}
$criterion = $newcriterion;
// Checking the number of cells.
if (count($criterion) % 2 === 0) {
throw new ExpectationException(
......
......@@ -28,8 +28,8 @@
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
use Behat\Gherkin\Node\TableNode as TableNode,
Behat\Behat\Context\Step\Given as Given,
Behat\Behat\Context\Step\When as When;
Moodle\BehatExtension\Context\Step\Given as Given,
Moodle\BehatExtension\Context\Step\When as When;
/**
* Generic grading methods step definitions.
......@@ -93,7 +93,7 @@ class behat_grading extends behat_base {
// Shortcut in case we already are in the grading page.
$usergradetextliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($usergradetext);
if ($this->getSession()->getPage()->find('named', array('link', $usergradetextliteral))) {
if ($this->getSession()->getPage()->find('named_partial', array('link', $usergradetextliteral))) {
return $gradeuserstep;
}
......
......@@ -27,8 +27,8 @@
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given,
Behat\Behat\Context\Step\Then,
use Moodle\BehatExtension\Context\Step\Given,
Moodle\BehatExtension\Context\Step\Then,
Behat\Mink\Exception\ExpectationException as ExpectationException,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
......
......@@ -27,7 +27,7 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given,
use Moodle\BehatExtension\Context\Step\Given as Given,
Behat\Gherkin\Node\TableNode as TableNode;
class behat_grade extends behat_base {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment