You are here

public function GeneralTest::testBasicForm in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php \Behat\Mink\Tests\Driver\Form\GeneralTest::testBasicForm()

File

vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php, line 20

Class

GeneralTest

Namespace

Behat\Mink\Tests\Driver\Form

Code

public function testBasicForm() {
  $this
    ->getSession()
    ->visit($this
    ->pathTo('/basic_form.html'));
  $webAssert = $this
    ->getAssertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->assertEquals('Basic Form Page', $webAssert
    ->elementExists('css', 'h1')
    ->getText());
  $firstname = $webAssert
    ->fieldExists('first_name');
  $lastname = $webAssert
    ->fieldExists('lastn');
  $this
    ->assertEquals('Firstname', $firstname
    ->getValue());
  $this
    ->assertEquals('Lastname', $lastname
    ->getValue());
  $firstname
    ->setValue('Konstantin');
  $page
    ->fillField('last_name', 'Kudryashov');
  $this
    ->assertEquals('Konstantin', $firstname
    ->getValue());
  $this
    ->assertEquals('Kudryashov', $lastname
    ->getValue());
  $page
    ->findButton('Reset')
    ->click();
  $this
    ->assertEquals('Firstname', $firstname
    ->getValue());
  $this
    ->assertEquals('Lastname', $lastname
    ->getValue());
  $firstname
    ->setValue('Konstantin');
  $page
    ->fillField('last_name', 'Kudryashov');
  $page
    ->findButton('Save')
    ->click();
  if ($this
    ->safePageWait(5000, 'document.getElementById("first") !== null')) {
    $this
      ->assertEquals('Anket for Konstantin', $webAssert
      ->elementExists('css', 'h1')
      ->getText());
    $this
      ->assertEquals('Firstname: Konstantin', $webAssert
      ->elementExists('css', '#first')
      ->getText());
    $this
      ->assertEquals('Lastname: Kudryashov', $webAssert
      ->elementExists('css', '#last')
      ->getText());
  }
}