You are here

public function LoginTest::testScrollBox in Legal 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/LoginTest.php \Drupal\Tests\legal\Functional\LoginTest::testScrollBox()

Test if T&Cs scroll box (textarea) displays and behaves correctly.

File

tests/src/Functional/LoginTest.php, line 48

Class

LoginTest
Tests a user loging into an account and accepting new T&C.

Namespace

Drupal\Tests\legal\Functional

Code

public function testScrollBox() {

  // Set conditions to display in an un-editable HTML text area.
  $this
    ->config('legal.settings')
    ->set('login_terms_style', 0)
    ->set('login_container', 0)
    ->save();

  // Log user in.
  $this
    ->drupalPostForm('user/login', $this->loginDetails, 'Log in');

  // Check T&Cs displayed as textarea.
  $readonly = $this
    ->assertSession()
    ->elementExists('css', 'textarea#edit-conditions')
    ->getAttribute('readonly');

  // Check textarea field is not editable.
  $this
    ->assertEquals($readonly, 'readonly');

  // Check textarea only contains plain text.
  $this
    ->assertSession()
    ->elementTextContains('css', 'textarea#edit-conditions', $this->conditionsPlainText);
}