Use data factory for test newsletter

MAILPOET-4236
This commit is contained in:
John Oleksowicz
2022-05-05 14:50:44 -05:00
committed by Veljko V
parent 0159418251
commit 780dd7f609
4 changed files with 5 additions and 24 deletions

View File

@ -1471,11 +1471,6 @@ parameters:
count: 1
path: ../../tests/acceptance/Subscribers/SubscriberCookieCest.php
-
message: "#^Parameter \\#1 \\$body of method MailPoet\\\\Entities\\\\NewsletterEntity\\:\\:setBody\\(\\) expects array\\|null, mixed given\\.$#"
count: 1
path: ../../tests/integration/API/JSON/v1/SendingQueueTest.php
-
message: "#^Parameter \\#1 \\$needle of method Codeception\\\\Verify\\\\Verify\\:\\:stringContainsString\\(\\) expects string, mixed given\\.$#"
count: 4

View File

@ -1476,11 +1476,6 @@ parameters:
count: 1
path: ../../tests/acceptance/Subscribers/SubscriberCookieCest.php
-
message: "#^Parameter \\#1 \\$body of method MailPoet\\\\Entities\\\\NewsletterEntity\\:\\:setBody\\(\\) expects array\\|null, mixed given\\.$#"
count: 1
path: ../../tests/integration/API/JSON/v1/SendingQueueTest.php
-
message: "#^Parameter \\#1 \\$needle of method Codeception\\\\Verify\\\\Verify\\:\\:stringContainsString\\(\\) expects string, mixed given\\.$#"
count: 4

View File

@ -1505,11 +1505,6 @@ parameters:
count: 1
path: ../../tests/acceptance/Subscribers/SubscriberCookieCest.php
-
message: "#^Parameter \\#1 \\$body of method MailPoet\\\\Entities\\\\NewsletterEntity\\:\\:setBody\\(\\) expects array\\|null, mixed given\\.$#"
count: 1
path: ../../tests/integration/API/JSON/v1/SendingQueueTest.php
-
message: "#^Parameter \\#1 \\$needle of method Codeception\\\\Verify\\\\Verify\\:\\:stringContainsString\\(\\) expects string, mixed given\\.$#"
count: 4

View File

@ -2,7 +2,6 @@
namespace MailPoet\Test\API\JSON\v1;
use Codeception\Util\Fixtures;
use Codeception\Util\Stub;
use MailPoet\API\JSON\Response as APIResponse;
use MailPoet\API\JSON\v1\SendingQueue as SendingQueueAPI;
@ -29,12 +28,10 @@ class SendingQueueTest extends \MailPoetTest {
parent::_before();
$this->clean();
$this->newsletter = new NewsletterEntity();
$this->newsletter->setSubject('My Standard Newsletter');
$this->newsletter->setBody(json_decode(Fixtures::get('newsletter_body_template'), true));
$this->newsletter->setType(NewsletterEntity::TYPE_STANDARD);
$this->entityManager->persist($this->newsletter);
$this->entityManager->flush();
$this->newsletter = (new Newsletter())
->withSubject('My Standard Newsletter')
->withDefaultBody()
->create();
$settings = SettingsController::getInstance();
$settings->set('sender', [
@ -128,11 +125,10 @@ class SendingQueueTest extends \MailPoetTest {
}
public function testItRejectsInvalidNewsletters() {
$newsletter = (new Newsletter())->create();
$sendingQueue = $this->getServiceWithOverrides(SendingQueueAPI::class, [
'newsletterValidator' => Stub::make(NewsletterValidator::class, ['validate' => 'some error'])
]);
$response = $sendingQueue->add(['newsletter_id' => $newsletter->getId()]);
$response = $sendingQueue->add(['newsletter_id' => $this->newsletter->getId()]);
$response = $response->getData();
expect($response['errors'][0])->array();
expect($response['errors'][0]['message'])->stringContainsString('some error');