public function StateDemoTest::testStateForm in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/form_api_example/tests/src/FunctionalJavascript/StateDemoTest.php \Drupal\Tests\form_api_example\FunctionalJavascript\StateDemoTest::testStateForm()
Functional tests for the StateDemo example form.
File
- form_api_example/
tests/ src/ FunctionalJavascript/ StateDemoTest.php, line 30
Class
- StateDemoTest
- @group form_api_example
Namespace
Drupal\Tests\form_api_example\FunctionalJavascriptCode
public function testStateForm() {
// Visit form route.
$route = Url::fromRoute('form_api_example.state_demo');
$this
->drupalGet($route);
// Get Mink stuff.
$page = $this
->getSession()
->getPage();
// Verify we can find the diet restrictions textfield, and that by default
// it is not visible.
$this
->assertNotEmpty($checkbox = $page
->find('css', 'input[name="diet"]'));
$this
->assertFalse($checkbox
->isVisible(), 'Diet restrictions field is not visible.');
// Check the needs special accommodation checkbox.
$page
->checkField('needs_accommodation');
// Verify the textfield is visible now.
$this
->assertTrue($checkbox
->isVisible(), 'Diet restrictions field is visible.');
}