Skip to content
Snippets Groups Projects

Issue #3418398: Refactors frequency session checking

1 file
+ 59
0
Compare changes
  • Side-by-side
  • Inline
<?php
namespace Drupal\Tests\agreement\Functional;
/**
* Tests user not required to agree after changing password.
*
* When an agreement requires a user to agree on every login, the user should
* not be required to agree when they change their password because Drupal
* considers this a session change and agreement considers a new session a new
* login.
*
* @group agreement
*/
class AgreementChangePasswordTest extends AgreementTestBase {
/**
* User account to test custom frequency.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $unprivilegedAccount;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Sets the frequency to a quarter of a day.
$settings = $this->agreement->getSettings();
$settings['frequency'] = 0;
$this->agreement->set('settings', $settings);
$this->agreement->save();
$this->unprivilegedAccount = $this->createUnprivilegedUser();
}
/**
* Tests that every login agreement gets auto-agreed after password change.
*/
public function testUpdatePassword(): void {
$this->drupalLogin($this->unprivilegedAccount);
$this->assertAgreementPage($this->agreement);
$this->assertAgreed($this->agreement);
$this->drupalGet('/user/' . $this->unprivilegedAccount->id() . '/edit');
$newPass = \Drupal::service('password_generator')->generate();
$this->submitForm([
'current_pass' => $this->unprivilegedAccount->passRaw,
'pass[pass1]' => $newPass,
'pass[pass2]' => $newPass,
], 'Save');
$this->assertNotAgreementPage($this->agreement);
}
}
Loading