Files
piratepoet/tests/integration/Subscription/CaptchaSessionTest.php
Amine Ben hammou 43df66d162 Add public keyword to methods
[MAILPOET-2413]
2019-12-26 18:09:45 +03:00

49 lines
1.6 KiB
PHP

<?php
namespace MailPoet\Test\Subscription;
use MailPoet\Subscription\CaptchaSession;
use MailPoet\WP\Functions as WPFunctions;
class CaptchaSessionTest extends \MailPoetTest {
const SESSION_ID = 'ABCD';
/** @var CaptchaSession */
private $captcha_session;
public function _before() {
$this->captcha_session = new CaptchaSession(new WPFunctions);
$this->captcha_session->init(self::SESSION_ID);
}
public function testItCanStoreAndRetrieveFormData() {
$form_data = ['email' => 'email@example.com'];
$this->captcha_session->setFormData($form_data);
expect($this->captcha_session->getFormData())->equals($form_data);
}
public function testItCanStoreAndRetrieveCaptchaHash() {
$hash = '1234';
$this->captcha_session->setCaptchaHash($hash);
expect($this->captcha_session->getCaptchaHash())->equals($hash);
}
public function testItCanResetSessionData() {
$this->captcha_session->setFormData(['email' => 'email@example.com']);
$this->captcha_session->setCaptchaHash('hash123');
$this->captcha_session->reset();
expect($this->captcha_session->getFormData())->false();
expect($this->captcha_session->getCaptchaHash())->false();
}
public function testItAssociatesDataWithSession() {
$hash = '1234';
$this->captcha_session->setCaptchaHash($hash);
expect($this->captcha_session->getCaptchaHash())->equals($hash);
$this->captcha_session->init();
expect($this->captcha_session->getCaptchaHash())->false();
$this->captcha_session->init(self::SESSION_ID);
expect($this->captcha_session->getCaptchaHash())->equals($hash);
}
}