Remove rest of usage old model SubscriberIP

[MAILPOET-3032]
This commit is contained in:
Jan Lysý
2021-04-07 08:06:01 +02:00
committed by Veljko V
parent 5ce4eeed10
commit 31bff0efb4
6 changed files with 41 additions and 25 deletions

View File

@ -3,8 +3,9 @@
namespace MailPoet\Test\Subscription;
use Codeception\Util\Fixtures;
use MailPoet\Entities\SubscriberIPEntity;
use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberIP;
use MailPoet\Subscribers\SubscriberIPsRepository;
use MailPoet\Subscription\Captcha;
use MailPoet\Subscription\CaptchaSession;
use MailPoet\Util\Cookies;
@ -24,9 +25,10 @@ class CaptchaTest extends \MailPoetTest {
public function _before() {
$cookiesMock = $this->createMock(Cookies::class);
$cookiesMock->method('get')->willReturn('abcd');
$subscriberIPsRepository = $this->diContainer->get(SubscriberIPsRepository::class);
$this->captchaSession = new CaptchaSession(new Functions());
$this->captchaSession->init(self::CAPTCHA_SESSION_ID);
$this->captcha = new Captcha(new WPFunctions, $this->captchaSession);
$this->captcha = new Captcha($subscriberIPsRepository, new WPFunctions, $this->captchaSession);
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$this->captchaSession->reset();
}
@ -47,10 +49,10 @@ class CaptchaTest extends \MailPoetTest {
}
public function testItRequiresCaptchaForRepeatedIPAddress() {
$ip = SubscriberIP::create();
$ip->ip = '127.0.0.1';
$ip->createdAt = Carbon::now()->subMinutes(1);
$ip->save();
$ip = new SubscriberIPEntity('127.0.0.1');
$ip->setCreatedAt(Carbon::now()->subMinutes(1));
$this->entityManager->persist($ip);
$this->entityManager->flush();
$email = 'non-existent-subscriber@example.com';
$result = $this->captcha->isRequired($email);
expect($result)->equals(true);
@ -64,6 +66,6 @@ class CaptchaTest extends \MailPoetTest {
}
public function _after() {
SubscriberIP::deleteMany();
$this->truncateEntity(SubscriberIPEntity::class);
}
}