You are here

public function AgreementDefaultsUnprivilegedUserTest::testAgreement in Agreement 3.0.x

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

Asserts that the default settings work for the end user.

File

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

Class

AgreementDefaultsUnprivilegedUserTest
Tests agreement when user does not have privileges.

Namespace

Drupal\Tests\agreement\Functional

Code

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

  // Sent to agreement page.
  $this
    ->assertAgreementPage($this->agreement);

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

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

  // Try submitting agreement form.
  $this
    ->assertNotAgreed($this->agreement);
  $this
    ->assertAgreementPage($this->agreement);
  $this
    ->drupalGet('/admin/config/people/agreement');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
}