AgreementCustomFrequencyTest.php in Agreement 3.0.x
File
tests/src/Functional/AgreementCustomFrequencyTest.php
View source
<?php
namespace Drupal\Tests\agreement\Functional;
class AgreementCustomFrequencyTest extends AgreementTestBase {
protected $unprivilegedAccount;
protected function setUp() : void {
parent::setUp();
$settings = $this->agreement
->getSettings();
$settings['frequency'] = 0.25;
$this->agreement
->set('settings', $settings);
$this->agreement
->save();
$this->unprivilegedAccount = $this
->createUnprivilegedUser();
}
public function testInvalidCustomFrequency() {
$this
->drupalLogin($this
->createPrivilegedUser());
$this
->drupalGet('/admin/config/people/agreement/manage/default');
$edit = [
'settings[frequency]' => '-0.25',
];
$this
->submitForm($edit, 'Save');
$this
->getSession()
->getPage()
->hasContent('Only -1 is an acceptable negative frequency.');
}
public function testAgreement() {
$this
->drupalLogin($this->unprivilegedAccount);
$this
->assertAgreementPage($this->agreement);
$this
->assertAgreed($this->agreement);
$moreThanSixHoursAgo = time() - 22000;
\Drupal::database()
->update('agreement')
->fields([
'agreed_date' => $moreThanSixHoursAgo,
])
->condition('uid', $this->unprivilegedAccount
->id())
->execute();
$this
->drupalGet('/node/2');
$this
->assertAgreementPage($this->agreement);
}
}