You are here

public function InstallTest::test in Lightning Core 8.4

Same name and namespace in other branches
  1. 8.3 modules/lightning_contact_form/tests/src/Functional/InstallTest.php \Drupal\Tests\lightning_contact_form\Functional\InstallTest::test()

Tests the site-wide contact form.

File

modules/lightning_contact_form/tests/src/Functional/InstallTest.php, line 22

Class

InstallTest
@group lightning @group lightning_core @group lightning_contact_form

Namespace

Drupal\Tests\lightning_contact_form\Functional

Code

public function test() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('/contact');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->fieldExists('Your name');
  $assert_session
    ->fieldExists('Your email address');
  $assert_session
    ->fieldExists('Subject');
  $assert_session
    ->fieldExists('Message');

  // The name and e-mail fields should not be present for authenticated users.
  $account = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('/contact');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->fieldNotExists('Your name');
  $assert_session
    ->fieldNotExists('Your email address');
  $assert_session
    ->fieldExists('Subject');
  $assert_session
    ->fieldExists('Message');
  $this
    ->drupalLogout();
}