Skip to content

Commit 2013c78

Browse files
author
Chris Burgess
committed
#590: Checkbox manipulation in regions
1 parent 40af5f3 commit 2013c78

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

features/blackbox.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Feature: Test DrupalContext
2626
Scenario: Submit a form in a region
2727
Given I am on the homepage
2828
When I fill in "Search…" with "Views" in the "navigation" region
29+
And I check "extra" in the "navigation" region
2930
And I press "Search" in the "navigation" region
3031
Then I should see the text "Search again" in the "right sidebar" region
3132

fixtures/blackbox/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ <h1 id="site-name">Drupal</h1>
1010
<form action="form.html">
1111
<label for="search">Search&hellip;</label>
1212
<input id="search" name="search" type="text"/>
13+
<input type="checkbox" name="extra" value="1" id="extra"><label for="extra">extra</label>
1314
<input type="submit" value="Search"/>
1415
</form>
1516
</div>

src/Drupal/DrupalExtension/Context/MinkContext.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public function assertRegionLinkFollow($link, $region)
402402
}
403403

404404
/**
405-
* Checks, if a button with id|name|title|alt|value exists or not and pressess the same
405+
* Checks if a button with id|name|title|alt|value exists or not and presses the same
406406
*
407407
* @Given I press :button in the :region( region)
408408
*
@@ -442,6 +442,44 @@ public function regionFillField($field, $value, $region)
442442
$regionObj->fillField($field, $value);
443443
}
444444

445+
/**
446+
* Checks if a checkbox with id|name|title|alt|value exists or not and checks the same
447+
*
448+
* @Given I check :locator in the :region( region)
449+
*
450+
* @param $locator
451+
* string The id|name|title|alt|value of the checkbox to be checked
452+
* @param $region
453+
* string The region in which the checkbox should be checked
454+
*
455+
* @throws \Exception
456+
* If region or checkbox within it cannot be found.
457+
*/
458+
public function assertRegionCheckBox($locator, $region)
459+
{
460+
$regionObj = $this->getRegion($region);
461+
$regionObj->checkField($locator);
462+
}
463+
464+
/**
465+
* Checks if a checkbox with id|name|title|alt|value exists or not and unchecks the same
466+
*
467+
* @Given I uncheck :checkbox in the :region( region)
468+
*
469+
* @param $locator
470+
* string The id|name|title|alt|value of the checkbox to be unchecked
471+
* @param $region
472+
* string The region in which the checkbox should be unchecked
473+
*
474+
* @throws \Exception
475+
* If region or checkbox within it cannot be found.
476+
*/
477+
public function assertRegionUncheckBox($locator, $region)
478+
{
479+
$regionObj = $this->getRegion($region);
480+
$regionObj->uncheckField($locator);
481+
}
482+
445483
/**
446484
* Find a heading in a specific region.
447485
*

0 commit comments

Comments
 (0)