public function AgreementRevokeTest::testAgreement in Agreement 3.0.x
Same name and namespace in other branches
- 8.2 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\FunctionalCode
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
->drupalGet('/agreement');
$this
->submitForm($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);
}