Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
42ad096f
Commit
42ad096f
authored
Dec 09, 2014
by
Rajesh Taneja
Browse files
MDL-46891 Behat: Added support for behat 3
parent
e8952c59
Changes
48
Hide whitespace changes
Inline
Side-by-side
admin/tests/behat/behat_admin.php
View file @
42ad096f
...
...
@@ -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
;
/**
...
...
admin/tool/behat/tests/manager_test.php
View file @
42ad096f
...
...
@@ -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
);
...
...
admin/tool/langimport/tests/behat/manage_langpacks.feature
View file @
42ad096f
...
...
@@ -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"
...
...
auth/tests/behat/behat_auth.php
View file @
42ad096f
...
...
@@ -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.
...
...
backup/util/ui/tests/behat/behat_backup.php
View file @
42ad096f
...
...
@@ -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
;
}
...
...
behat.yml.dist
View file @
42ad096f
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: { }
blocks/tests/behat/behat_blocks.php
View file @
42ad096f
...
...
@@ -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.
...
...
calendar/tests/behat/behat_calendar.php
View file @
42ad096f
...
...
@@ -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
;
/**
...
...
cohort/tests/behat/behat_cohort.php
View file @
42ad096f
...
...
@@ -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.
...
...
completion/tests/behat/behat_completion.php
View file @
42ad096f
...
...
@@ -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
;
/**
...
...
config-dist.php
View file @
42ad096f
...
...
@@ -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(
...
...
course/tests/behat/behat_course.php
View file @
42ad096f
...
...
@@ -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
{
...
...
course/tests/behat/category_resort.feature
View file @
42ad096f
...
...
@@ -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>
...
...
course/tests/behat/course_resort.feature
View file @
42ad096f
...
...
@@ -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>
...
...
enrol/tests/behat/behat_enrol.php
View file @
42ad096f
...
...
@@ -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
;
/**
...
...
grade/grading/form/guide/tests/behat/behat_gradingform_guide.php
View file @
42ad096f
...
...
@@ -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
;
...
...
grade/grading/form/rubric/tests/behat/behat_gradingform_rubric.php
View file @
42ad096f
...
...
@@ -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
(
...
...
grade/grading/tests/behat/behat_grading.php
View file @
42ad096f
...
...
@@ -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
;
}
...
...
grade/report/grader/tests/behat/behat_gradereport_grader.php
View file @
42ad096f
...
...
@@ -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
;
...
...
grade/tests/behat/behat_grade.php
View file @
42ad096f
...
...
@@ -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
{
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment