Add JSON endpoint for CAPTCHA rendering

To be used inside WP/WC registration form to construct URL for CAPTCHA page.

[MAILPOET-6325]
This commit is contained in:
Mustapha Hadid
2024-11-15 21:50:45 +03:00
committed by David Remer
parent d2ebfba8c3
commit df171fdcc7
7 changed files with 101 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
<?php declare(strict_types = 1);
namespace integration\API\JSON\v1;
use MailPoet\API\JSON\Response;
use MailPoet\API\JSON\v1\Captcha;
use MailPoet\Captcha\CaptchaSession;
use MailPoet\Captcha\CaptchaUrlFactory;
use MailPoet\Config\Populator;
class CaptchaTest extends \MailPoetTest {
public function _before() {
$populator = $this->diContainer->get(Populator::class);
$populator->up();
parent::_before();
}
public function testItCanRenderCaptcha(): void {
$captchaSession = $this->diContainer->get(CaptchaSession::class);
$urlFactory = $this->diContainer->get(CaptchaUrlFactory::class);
$captcha = new Captcha($captchaSession, $urlFactory);
$response = $captcha->render();
verify($response->status)->equals(Response::REDIRECT);
verify($response->location)->stringContainsString('mailpoet_router&endpoint=captcha&action=render&data=');
}
}