Regenerate CAPTCHA phrase using a custom request with cachebust to avoid caching

[MAILPOET-6038]
This commit is contained in:
Jan Jakes
2024-07-30 15:36:12 +02:00
committed by Aschepikov
parent 758cb09a77
commit ee6e22efa3
5 changed files with 52 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ use Codeception\Stub;
use Codeception\Stub\Expected;
use MailPoet\Router\Endpoints\Subscription;
use MailPoet\Subscription\Captcha\CaptchaRenderer;
use MailPoet\Subscription\Captcha\CaptchaSession;
use MailPoet\Subscription\Pages;
use MailPoet\Util\Request;
use MailPoet\WP\Functions as WPFunctions;
@@ -58,4 +59,13 @@ class SubscriptionTest extends \MailPoetTest {
$subscription = new Subscription($pages, $this->wp, $this->captchaRenderer, $this->request);
$subscription->unsubscribe($this->data);
}
public function testItRefreshesCaptcha(): void {
$captchaSession = $this->diContainer->get(CaptchaSession::class);
$captchaSession->setCaptchaHash('123', ['phrase' => 'abc']);
$subscription = new Subscription($this->make(Pages::class), $this->wp, $this->captchaRenderer, $this->request);
$subscription->captchaRefresh(['captcha_session_id' => '123']);
$this->assertNotEquals('abc', $captchaSession->getCaptchaHash('123')['phrase']);
}
}