You are here

public function AgreementMultipleRoleTest::testAgreementForFirstRole in Agreement 3.0.x

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

Asserts that the user with the first role gets the agreement page.

File

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

Class

AgreementMultipleRoleTest
Tests agreement that applies to multiple roles.

Namespace

Drupal\Tests\agreement\Functional

Code

public function testAgreementForFirstRole() {

  // Create the user account.
  $requiredUser = $this
    ->createUnprivilegedUser();
  $requiredUser
    ->addRole($this->requiredRole);
  $requiredUser
    ->save();

  // Log in as the user.
  $this
    ->drupalLogin($requiredUser);

  // 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/' . $requiredUser
    ->id());
  $this
    ->assertAgreementPage($this->agreement);

  // Try submitting agreement form.
  $this
    ->assertNotAgreed($this->agreement);
  $this
    ->assertAgreementPage($this->agreement);
}