You are here

public function AgreementRevokeTest::testAgreement in Agreement 8.2

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

Asserts that an user that has agreed can revoke the agreement.

File

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

Class

AgreementRevokeTest
Tests the "revoke agreement" functionality.

Namespace

Drupal\Tests\agreement\Functional

Code

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

  // Agree to the agreement on presented after login.
  $this
    ->assertAgreed($this->agreement);
  $this
    ->assertNotAgreementPage($this->agreement);

  // Cancel the agreement.
  $settings = $this->agreement
    ->getSettings();
  $edit = [
    'agree' => '0',
  ];
  $this
    ->drupalPostForm('/agreement', $edit, $settings['submit']);
  $this
    ->assertSession()
    ->pageTextContains('You have successfully revoked your acceptance of our agreement. ');

  // Assert agreement page after revoking.
  $this
    ->drupalGet('/node/' . $this->node
    ->id());
  $this
    ->assertAgreementPage($this->agreement);

  // Assert that the user can re-accept the agreement.
  $this
    ->assertAgreed($this->agreement);
  $this
    ->assertNotAgreementPage($this->agreement);
}