You are here

public function BrowserTestBaseTest::testForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php \Drupal\Tests\simpletest\Functional\BrowserTestBaseTest::testForm()

Tests basic form functionality.

File

core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php, line 47
Contains \Drupal\Tests\simpletest\Functional\BrowserTestBaseTest.

Class

BrowserTestBaseTest
Tests BrowserTestBase functionality.

Namespace

Drupal\Tests\simpletest\Functional

Code

public function testForm() {

  // Ensure the proper response code for a _form route.
  $this
    ->drupalGet('form-test/object-builder');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Ensure the form and text field exist.
  $this
    ->assertSession()
    ->elementExists('css', 'form#form-test-form-test-object');
  $this
    ->assertSession()
    ->fieldExists('bananas');
  $edit = [
    'bananas' => 'green',
  ];
  $this
    ->submitForm($edit, 'Save', 'form-test-form-test-object');
  $config_factory = $this->container
    ->get('config.factory');
  $value = $config_factory
    ->get('form_test.object')
    ->get('bananas');
  $this
    ->assertSame('green', $value);
}