mailgun-php/tests/Messages/StandardMessageTest.php

55 lines
1.8 KiB
PHP
Raw Normal View History

2013-08-13 23:26:34 +04:00
<?PHP
2016-07-24 14:42:47 +03:00
/*
* Copyright (C) 2013-2016 Mailgun
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
2013-08-13 23:26:34 +04:00
namespace Mailgun\Tests\Messages;
use Mailgun\Tests\Mock\Mailgun;
2013-08-13 23:26:34 +04:00
2014-05-14 17:06:05 +04:00
class StandardMessageTest extends \Mailgun\Tests\MailgunTestCase
{
private $client;
2016-07-24 14:42:47 +03:00
private $sampleDomain = 'samples.mailgun.org';
2013-08-13 23:26:34 +04:00
2014-05-14 17:06:05 +04:00
public function setUp()
{
2016-07-24 14:42:47 +03:00
$this->client = new Mailgun('My-Super-Awesome-API-Key');
2014-05-14 17:06:05 +04:00
}
public function testSendMIMEMessage()
{
2016-07-24 14:42:47 +03:00
$customMime = 'Received: by luna.mailgun.net with SMTP mgrt 8728174999085; Mon, 10 Jun 2013 09:50:58 +0000
2013-08-13 23:26:34 +04:00
Mime-Version: 1.0
2016-07-24 14:42:47 +03:00
Content-Type: text/plain; charset="ascii"
2013-08-13 23:26:34 +04:00
Subject: This is the Subject!
From: Mailgun Testing <test@test.mailgun.com>
To: test@test.mailgun.com
Message-Id: <20130610095049.30790.4334@test.mailgun.com>
Content-Transfer-Encoding: 7bit
X-Mailgun-Sid: WyIxYTdhMyIsICJmaXplcmtoYW5AcXVhZG1zLmluIiwgImExOWQiXQ==
Date: Mon, 10 Jun 2013 09:50:58 +0000
Sender: test@test.mailgun.com
2016-07-24 14:42:47 +03:00
Mailgun is testing!';
$envelopeFields = ['to' => 'test@test.mailgun.org'];
$result = $this->client->sendMessage('test.mailgun.org', $envelopeFields, $customMime);
$this->assertEquals('test.mailgun.org/messages.mime', $result->http_endpoint_url);
2014-05-14 17:06:05 +04:00
}
public function testSendMessage()
{
$message = ['to' => 'test@test.mailgun.org',
'from' => 'sender@test.mailgun.org',
2014-05-14 17:06:05 +04:00
'subject' => 'This is my test subject',
'text' => 'Testing!',
2016-07-24 14:42:47 +03:00
];
$result = $this->client->sendMessage('test.mailgun.org', $message);
$this->assertEquals('test.mailgun.org/messages', $result->http_endpoint_url);
2014-05-14 17:06:05 +04:00
}
2013-08-13 23:26:34 +04:00
}