You are here

public function AgreementDefaultsPrivilegedUserTest::testAgreement in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/AgreementDefaultsPrivilegedUserTest.php \Drupal\Tests\agreement\Functional\AgreementDefaultsPrivilegedUserTest::testAgreement()

Asserts that the default settings work for the admin user.

File

tests/src/Functional/AgreementDefaultsPrivilegedUserTest.php, line 15

Class

AgreementDefaultsPrivilegedUserTest
Tests the default agreement with a privileged user.

Namespace

Drupal\Tests\agreement\Functional

Code

public function testAgreement() {
  $account = $this
    ->createPrivilegedUser();
  $this
    ->drupalLogin($account);

  // After save, re-open agreement settings.
  $this
    ->drupalGet('admin/config/people/agreement/manage/default');
  $this
    ->assertSession()
    ->titleEquals('Manage Agreement: Default agreement | Drupal');

  // Go to front page, no agreement.
  $this
    ->drupalGet('/node');
  $this
    ->assertNotAgreementPage($this->agreement);

  // Go anywhere else, open agreement.
  $this
    ->drupalGet('/admin');
  $this
    ->assertAgreementPage($this->agreement);

  // Try to go somewhere without submitting.
  $this
    ->drupalGet('/node/add');
  $this
    ->assertAgreementPage($this->agreement);

  // Try submitting agreement form.
  $this
    ->assertNotAgreed($this->agreement);
  $this
    ->assertAgreed($this->agreement);
  $this
    ->drupalGet('/admin');
  $this
    ->assertNotAgreementPage($this->agreement);
}