You are here

public function AgreementMultipleRoleTest::testAgreementForSecondRole in Agreement 8.2

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

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

File

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

Class

AgreementMultipleRoleTest
Tests agreement that applies to multiple roles.

Namespace

Drupal\Tests\agreement\Functional

Code

public function testAgreementForSecondRole() {

  // Create the user account.
  $requiredUser = $this
    ->createUnprivilegedUser();
  $requiredUser
    ->addRole($this->requiredSecondRole);
  $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);
}