Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fix SparkpostTransportMessageTest.php static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-navghane committed Jul 24, 2023
1 parent 120e67e commit 85fdfe5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Tests/Unit/Mailer/Transport/SparkpostTransportMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Mautic\EmailBundle\Mailer\Message\MauticMessage;
use Mautic\EmailBundle\Model\TransportCallback;
use MauticPlugin\SparkpostBundle\Mailer\Transport\SparkpostTransport;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -59,19 +60,18 @@ public function testCcAndBccFields(): void
['tokens' => ['{formfield=first_name}' => '1'], 'emailId' => $emailId, 'emailName' => $internalEmailName] // @phpstan-ignore-line
);

/** @phpstan-ignore-next-line */
$message->addMetadata('[email protected]', ['tokens' => ['{formfield=first_name}' => '2']]); // @phpstan-ignore-line

$sentMessageMock = $this->createMock(SentMessage::class);
$sentMessageMock->method('getOriginalMessage')
->willReturn($message);

$payload = $this->invokeInaccessibleMethod($sparkpost, 'getSparkpostPayload', [$sentMessageMock]);
$this->assertSame(sprintf('%s:%s', $emailId, $expectedInternalEmailName), $payload['campaign_id']);
$this->assertEquals('[email protected]', $payload['content']['from']);
$this->assertEquals('Test subject', $payload['content']['subject']);
$this->assertEquals('First Name: {{{ FORMFIELDFIRSTNAME }}}', $payload['content']['html']);
$this->assertCount(10, $payload['recipients']);
Assert::assertEquals(sprintf('%s:%s', $emailId, $expectedInternalEmailName), $payload['campaign_id']);
Assert::assertEquals('[email protected]', $payload['content']['from']);
Assert::assertEquals('Test subject', $payload['content']['subject']);
Assert::assertEquals('First Name: {{{ FORMFIELDFIRSTNAME }}}', $payload['content']['html']);
Assert::assertCount(10, $payload['recipients']);

// CC and BCC fields has to be included as normal recipient with same data as TO fields has
$recipients = [
Expand Down Expand Up @@ -171,7 +171,7 @@ public function testCcAndBccFields(): void
],
];

$this->assertEquals($recipients, $payload['recipients']);
Assert::assertEquals($recipients, $payload['recipients']);
}

/**
Expand Down

0 comments on commit 85fdfe5

Please sign in to comment.