2017-03-26 11:23:03 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2017-11-22 11:37:04 +03:00
|
|
|
* Copyright (C) 2013 Mailgun
|
2017-03-26 11:23:03 +03:00
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Mailgun\Tests\Functional;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author James Kraus <jkraus@imagineteam.com>
|
|
|
|
*/
|
|
|
|
class MessageBuilderHeaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testSimpleExample()
|
|
|
|
{
|
|
|
|
$messageValidator = function ($headers) {
|
|
|
|
$this->assertContains(['name' => 'h:My-Singular-Header', 'contents' => '123'], $headers);
|
2017-04-08 02:24:37 +03:00
|
|
|
$this->assertContains(['name' => 'h:My-Plural-Header', 'contents' => '123'], $headers);
|
|
|
|
$this->assertContains(['name' => 'h:My-Plural-Header', 'contents' => '456'], $headers);
|
2017-03-26 11:23:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create the mocked mailgun client.
|
2017-03-26 11:49:33 +03:00
|
|
|
$mailgun = MockedMailgun::createMock($this, 'POST', 'domain/messages', [], $messageValidator);
|
2017-03-26 11:23:03 +03:00
|
|
|
|
|
|
|
$builder = $mailgun->MessageBuilder();
|
|
|
|
|
|
|
|
$builder->addCustomHeader('My-Singular-Header', '123');
|
|
|
|
$builder->addCustomHeader('My-Plural-Header', '123');
|
|
|
|
$builder->addCustomHeader('My-Plural-Header', '456');
|
|
|
|
|
|
|
|
$builder->setFromAddress('from@example.com');
|
|
|
|
$builder->addToRecipient('to@example.com');
|
|
|
|
$builder->setSubject('Foo');
|
|
|
|
$builder->setTextBody('Bar');
|
|
|
|
|
|
|
|
$mailgun->sendMessage('domain', $builder->getMessage());
|
|
|
|
}
|
|
|
|
}
|