StateDemoTest.php in Examples for Developers 8
File
form_api_example/tests/src/FunctionalJavascript/StateDemoTest.php
View source
<?php
namespace Drupal\Tests\form_api_example\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Core\Url;
class StateDemoTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'form_api_example',
];
public function testStateForm() {
$route = Url::fromRoute('form_api_example.state_demo');
$this
->drupalGet($route);
$page = $this
->getSession()
->getPage();
$this
->assertNotEmpty($checkbox = $page
->find('css', 'input[name="diet"]'));
$this
->assertFalse($checkbox
->isVisible(), 'Diet restrictions field is not visible.');
$page
->checkField('needs_accommodation');
$this
->assertTrue($checkbox
->isVisible(), 'Diet restrictions field is visible.');
}
}