Skip to content

Commit

Permalink
fix rogue tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
balvig committed Sep 5, 2022
1 parent 863da75 commit 48d17db
Showing 1 changed file with 89 additions and 89 deletions.
178 changes: 89 additions & 89 deletions tests/TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@

class MailPostmarkTransportTest extends TestCase {

public function testSend() {
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Is alive!');
$message->addTo('[email protected]', 'A. Friend');
$message->addTo('[email protected]');
$message->addCc('[email protected]');
$message->addCc('[email protected]', 'Extra 2');
$message->addBcc('[email protected]');
$message->addBcc('[email protected]', 'Extra 4');
$message->addPart('<q>Help me Rhonda</q>', 'text/html');
$message->addPart('Doo-wah-ditty.', 'text/plain');

$attachment = new Swift_Attachment('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2 = new Swift_Attachment('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2->setDisposition('inline');

$message->attach($attachment);
$message->attach($attachment2);
$message->setPriority(1);

$headers = $message->getHeaders();
$headers->addTextHeader('X-PM-Tag', 'movie-quotes');

$transport = new PostmarkTransportStub([new Response(200)]);

$recipientCount = $transport->send($message);

$this->assertEquals(6, $recipientCount);
$transaction = $transport->getHistory()[0];
$this->assertExpectedMessageRequest($message, $transaction['request']);
}
public function testSend() {
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Is alive!');
$message->addTo('[email protected]', 'A. Friend');
$message->addTo('[email protected]');
$message->addCc('[email protected]');
$message->addCc('[email protected]', 'Extra 2');
$message->addBcc('[email protected]');
$message->addBcc('[email protected]', 'Extra 4');
$message->addPart('<q>Help me Rhonda</q>', 'text/html');
$message->addPart('Doo-wah-ditty.', 'text/plain');

$attachment = new Swift_Attachment('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2 = new Swift_Attachment('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2->setDisposition('inline');

$message->attach($attachment);
$message->attach($attachment2);
$message->setPriority(1);

$headers = $message->getHeaders();
$headers->addTextHeader('X-PM-Tag', 'movie-quotes');

$transport = new PostmarkTransportStub([new Response(200)]);

$recipientCount = $transport->send($message);

$this->assertEquals(6, $recipientCount);
$transaction = $transport->getHistory()[0];
$this->assertExpectedMessageRequest($message, $transaction['request']);
}

protected function assertExpectedMessageRequest($message, $request)
{
Expand Down Expand Up @@ -80,9 +80,9 @@ protected function assertExpectedMessageRequest($message, $request)
],
]
], json_decode($request->getBody()->getContents(), true));
}
}

public function testCanSendEmailsWithCCs()
public function testCanSendEmailsWithCCs()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
Expand Down Expand Up @@ -161,66 +161,66 @@ public function testFailedResponse()
$transport->send($message);
}

public function testMessageStreamViaDefaultHeaders()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Some Subject');
$message->addBcc('[email protected]', 'A. Friend');
$message->addBcc('[email protected]', 'B. Friend');

$transport = new PostmarkTransportStub([new Response(200)], ['X-PM-Message-Stream' => 'your-custom-stream']);
$transport->send($message);

$request = $transport->getHistory()[0]['request'];
$body = json_decode($request->getBody()->getContents(), true);

$this->assertCount(4, $body['Headers']);
$this->assertEquals(['Name' => 'X-PM-Message-Stream', 'Value' => 'your-custom-stream'], $body['Headers'][3]);
}

public function testMessageStreamViaHeaderOverwritesDefaultHeaders()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Some Subject');
$message->addBcc('[email protected]', 'A. Friend');
$message->addBcc('[email protected]', 'B. Friend');
$message->getHeaders()->addTextHeader('X-PM-Message-Stream', 'message-custom-stream');

$transport = new PostmarkTransportStub([new Response(200)], ['X-PM-Message-Stream' => 'my-custom-stream']);
$transport->send($message);

$request = $transport->getHistory()[0]['request'];
$body = json_decode($request->getBody()->getContents(), true);

$this->assertCount(4, $body['Headers']);
$this->assertEquals(['Name' => 'X-PM-Message-Stream', 'Value' => 'message-custom-stream'], $body['Headers'][3]);
}

public function testPmTagDeaultHeader()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Some Subject');
$message->addBcc('[email protected]', 'A. Friend');
$message->addBcc('[email protected]', 'B. Friend');

$transport = new PostmarkTransportStub([new Response(200)], ['X-PM-Tag' => 'my-tag']);
$transport->send($message);

$request = $transport->getHistory()[0]['request'];
$body = json_decode($request->getBody()->getContents(), true);

$this->assertEquals('my-tag', $body['Tag']);
}
public function testMessageStreamViaDefaultHeaders()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Some Subject');
$message->addBcc('[email protected]', 'A. Friend');
$message->addBcc('[email protected]', 'B. Friend');

$transport = new PostmarkTransportStub([new Response(200)], ['X-PM-Message-Stream' => 'your-custom-stream']);
$transport->send($message);

$request = $transport->getHistory()[0]['request'];
$body = json_decode($request->getBody()->getContents(), true);

$this->assertCount(4, $body['Headers']);
$this->assertEquals(['Name' => 'X-PM-Message-Stream', 'Value' => 'your-custom-stream'], $body['Headers'][3]);
}

public function testMessageStreamViaHeaderOverwritesDefaultHeaders()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Some Subject');
$message->addBcc('[email protected]', 'A. Friend');
$message->addBcc('[email protected]', 'B. Friend');
$message->getHeaders()->addTextHeader('X-PM-Message-Stream', 'message-custom-stream');

$transport = new PostmarkTransportStub([new Response(200)], ['X-PM-Message-Stream' => 'my-custom-stream']);
$transport->send($message);

$request = $transport->getHistory()[0]['request'];
$body = json_decode($request->getBody()->getContents(), true);

$this->assertCount(4, $body['Headers']);
$this->assertEquals(['Name' => 'X-PM-Message-Stream', 'Value' => 'message-custom-stream'], $body['Headers'][3]);
}

public function testPmTagDeaultHeader()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Some Subject');
$message->addBcc('[email protected]', 'A. Friend');
$message->addBcc('[email protected]', 'B. Friend');

$transport = new PostmarkTransportStub([new Response(200)], ['X-PM-Tag' => 'my-tag']);
$transport->send($message);

$request = $transport->getHistory()[0]['request'];
$body = json_decode($request->getBody()->getContents(), true);

$this->assertEquals('my-tag', $body['Tag']);
}
}


class PostmarkTransportStub extends Postmark\Transport {
protected $client;
protected $client;

public function __construct(array $responses = [], array $defaultHeaders = [])
public function __construct(array $responses = [], array $defaultHeaders = [])
{
parent::__construct('TESTING_SERVER', $defaultHeaders);

Expand Down

0 comments on commit 48d17db

Please sign in to comment.