class StateDemoTest

Tests the behavior of the StateDemo example.

@group form_api_example

Hierarchy

  • class \Drupal\Tests\form_api_example\FunctionalJavascript\StateDemoTest extends \Drupal\FunctionalJavascriptTests\WebDriverTestBase

Expanded class hierarchy of StateDemoTest

Related topics

File

modules/form_api_example/tests/src/FunctionalJavascript/StateDemoTest.php, line 15

Namespace

Drupal\Tests\form_api_example\FunctionalJavascript
View source
class StateDemoTest extends WebDriverTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * Our module dependencies.
   *
   * @var string[]
   */
  protected static $modules = [
    'form_api_example',
  ];
  
  /**
   * Functional tests for the StateDemo example form.
   */
  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.');
  }

}

Members

Title Sort descending Modifiers Object type Summary
StateDemoTest::$defaultTheme protected property
StateDemoTest::$modules protected static property Our module dependencies.
StateDemoTest::testStateForm public function Functional tests for the StateDemo example form.