public function AgreementMultipleTest::testAgreement in Agreement 8.2
Same name and namespace in other branches
- 3.0.x tests/src/Functional/AgreementMultipleTest.php \Drupal\Tests\agreement\Functional\AgreementMultipleTest::testAgreement()
Asserts that an user can use multiple agreements.
File
- tests/
src/ Functional/ AgreementMultipleTest.php, line 58
Class
- AgreementMultipleTest
- Tests multiple agreements.
Namespace
Drupal\Tests\agreement\FunctionalCode
public function testAgreement() {
$account = $this
->createUnprivilegedUser();
$this
->drupalLogin($account);
// Go to front page, no agreement.
$this
->drupalGet('/node');
$this
->assertNotAgreementPage($this->agreement);
$this
->assertNotAgreementpage($this->newAgreement);
// Go anywhere else, open agreement.
$this
->drupalGet('/user');
$this
->assertAgreementPage($this->agreement);
$this
->assertNotAgreementPage($this->newAgreement);
// Agreement with visibility settings for all pages displays instead of
// agreement with explicity visibility page settings.
$this
->drupalGet('/node/' . $this->node
->id());
$this
->assertAgreementPage($this->agreement);
$this
->assertNotAgreementPage($this->newAgreement);
// Accept the agreement.
$this
->assertAgreed($this->agreement);
// Go to the node again, which is second agreement page.
$this
->drupalGet('/node/' . $this->node
->id());
$this
->assertAgreementPage($this->newAgreement);
$this
->assertNotAgreementPage($this->agreement);
// Accept the second agreement.
$this
->assertAgreed($this->newAgreement);
$this
->assertNotAgreementPage($this->agreement);
}