AgreementMultipleTest.php in Agreement 3.0.x
File
tests/src/Functional/AgreementMultipleTest.php
View source
<?php
namespace Drupal\Tests\agreement\Functional;
use Drupal\agreement\Entity\Agreement;
class AgreementMultipleTest extends AgreementTestBase {
protected $newAgreement;
protected function setUp() : void {
parent::setUp();
$this->newAgreement = Agreement::create([
'id' => 'new_agreement',
'label' => 'New Agreement',
'path' => '/new-agreement',
'agreement' => '',
'settings' => [
'title' => $this->randomGenerator
->sentences(1),
'format' => 'plain_text',
'frequency' => -1,
'submit' => 'Submit',
'checkbox' => 'I agree',
'success' => 'Success',
'revoked' => 'Revoked',
'failure' => 'Failure',
'roles' => [
'authenticated',
],
'recipient' => '',
'reset_date' => 0,
'destination' => '',
'visibility' => [
'settings' => 1,
'pages' => [
'/node/' . $this->node
->id(),
],
],
],
]);
$this->newAgreement
->save();
$this->container
->get('router.builder')
->rebuild();
}
public function testAgreement() {
$account = $this
->createUnprivilegedUser();
$this
->drupalLogin($account);
$this
->drupalGet('/node');
$this
->assertNotAgreementPage($this->agreement);
$this
->assertNotAgreementpage($this->newAgreement);
$this
->drupalGet('/user');
$this
->assertAgreementPage($this->agreement);
$this
->assertNotAgreementPage($this->newAgreement);
$this
->drupalGet('/node/' . $this->node
->id());
$this
->assertAgreementPage($this->agreement);
$this
->assertNotAgreementPage($this->newAgreement);
$this
->assertAgreed($this->agreement);
$this
->drupalGet('/node/' . $this->node
->id());
$this
->assertAgreementPage($this->newAgreement);
$this
->assertNotAgreementPage($this->agreement);
$this
->assertAgreed($this->newAgreement);
$this
->assertNotAgreementPage($this->agreement);
}
}