Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
310
Merge Requests
310
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
d2f5b62f
Commit
d2f5b62f
authored
Sep 12, 2017
by
xjm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2907485
by Lendude, jonathan1055: Add getAllOptions() to AssertLegacyTrait
parent
2e3db915
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php
...m/tests/modules/form_test/src/Form/FormTestSelectForm.php
+8
-0
core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
+18
-0
core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+4
-0
No files found.
core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php
View file @
d2f5b62f
...
...
@@ -115,6 +115,14 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#multiple'
=>
TRUE
,
];
$form
[
'opt_groups'
]
=
[
'#type'
=>
'select'
,
'#options'
=>
[
'optgroup_one'
=>
[
'one'
=>
'one'
,
'two'
=>
'two'
,
'three'
=>
'three'
,
'four'
=>
'<strong>four</strong>'
],
'optgroup_two'
=>
[
'five'
=>
'five'
,
'six'
=>
'six'
],
],
];
$form
[
'submit'
]
=
[
'#type'
=>
'submit'
,
'#value'
=>
'Submit'
];
return
$form
;
}
...
...
core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
View file @
d2f5b62f
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\FunctionalTests
;
use
Behat\Mink\Element\NodeElement
;
use
Behat\Mink\Exception\ExpectationException
;
use
Behat\Mink\Selector\Xpath\Escaper
;
use
Drupal\Component\Render\FormattableMarkup
;
...
...
@@ -812,4 +813,21 @@ protected function getRawContent() {
return
$this
->
getSession
()
->
getPage
()
->
getContent
();
}
/**
* Get all option elements, including nested options, in a select.
*
* @param \Behat\Mink\Element\NodeElement $element
* The element for which to get the options.
*
* @return \Behat\Mink\Element\NodeElement[]
* Option elements in select.
*
* @deprecated Scheduled for removal in Drupal 9.0.0.
* Use $element->findAll('xpath', 'option') instead.
*/
protected
function
getAllOptions
(
NodeElement
$element
)
{
@
trigger_error
(
'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.'
,
E_USER_DEPRECATED
);
return
$element
->
findAll
(
'xpath'
,
'//option'
);
}
}
core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
View file @
d2f5b62f
...
...
@@ -434,6 +434,10 @@ public function testLegacyFieldAssertsForOptions() {
catch
(
\
PHPUnit_Framework_ExpectationFailedException
$e
)
{
$this
->
pass
(
$e
->
getMessage
());
}
// Test \Drupal\FunctionalTests\AssertLegacyTrait::getAllOptions.
$this
->
drupalGet
(
'/form-test/select'
);
$this
->
assertCount
(
6
,
$this
->
getAllOptions
(
$this
->
cssSelect
(
'select[name="opt_groups"]'
)[
0
]));
}
/**
...
...
Write
Preview
Markdown
is supported
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