Files
piratepoet/mailpoet/tests/integration/Util/Notices/PendingApprovalNoticeTest.php
Rodrigo Primo 0d2f6e0776 Replace expect()->stringContainsString() with verify()->stringContainsString()
codeception/verify 2.1 removed support for expect()->stringContainsString() so we need
to replace it with verify()->stringContainsString().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00

66 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php declare(strict_types = 1);
namespace MailPoet\Util\Notices;
use MailPoet\Mailer\Mailer;
use MailPoet\Services\Bridge;
use MailPoet\Settings\SettingsController;
class PendingApprovalNoticeTest extends \MailPoetTest {
/** @var PendingApprovalNotice */
private $notice;
/** @var SettingsController */
private $settings;
public function _before() {
parent::_before();
$this->settings = SettingsController::getInstance();
$this->notice = new PendingApprovalNotice($this->settings);
$this->settings->set('mta.mailpoet_api_key_state.state', Bridge::KEY_VALID);
}
public function testItDisplays(): void {
$this->settings->set('mta.mailpoet_api_key_state.data.is_approved', false);
$this->settings->set('mta.method', Mailer::METHOD_MAILPOET);
$result = $this->notice->init(true);
// check that the notice is displayed. We cannot check the whole string because it contains HTML tags
verify($result)->stringContainsString('Your subscription is currently');
verify($result)->stringContainsString('if you havent heard from our team about your subscription status in the past 48 hours.');
}
public function testItDoesNotDisplayWhenMSSKeyIsNotValid(): void {
$this->settings->set('mta.mailpoet_api_key_state.data.is_approved', false);
$this->settings->set('mta.mailpoet_api_key_state.state', Bridge::KEY_VALID_UNDERPRIVILEGED);
$this->settings->set('mta.method', Mailer::METHOD_MAILPOET);
$result = $this->notice->init(true);
verify($result)->null();
}
public function testItDoesNotDisplayWhenDisabled(): void {
$this->settings->set('mta.mailpoet_api_key_state.data.is_approved', false);
$this->settings->set('mta.method', Mailer::METHOD_MAILPOET);
$result = $this->notice->init(false);
verify($result)->null();
}
public function testItDoesNotDisplayWhenNotUsingMailPoet(): void {
$this->settings->set('mta.mailpoet_api_key_state.data.is_approved', false);
$this->settings->set('mta.method', Mailer::METHOD_PHPMAIL);
$result = $this->notice->init(true);
verify($result)->null();
}
public function testItDoesNotDisplayWhenApproved(): void {
$this->settings->set('mta.mailpoet_api_key_state.data.is_approved', true);
$this->settings->set('mta.method', Mailer::METHOD_MAILPOET);
$result = $this->notice->init(true);
verify($result)->null();
}
}