StandardMessageTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?PHP
  2. namespace Mailgun\Tests\Messages;
  3. use Mailgun\Tests\Mock\Mailgun;
  4. class StandardMessageTest extends \Mailgun\Tests\MailgunTestCase
  5. {
  6. private $client;
  7. private $sampleDomain = "samples.mailgun.org";
  8. public function setUp()
  9. {
  10. $this->client = new Mailgun("My-Super-Awesome-API-Key");
  11. }
  12. public function testSendMIMEMessage()
  13. {
  14. $customMime = "Received: by luna.mailgun.net with SMTP mgrt 8728174999085; Mon, 10 Jun 2013 09:50:58 +0000
  15. Mime-Version: 1.0
  16. Content-Type: text/plain; charset=\"ascii\"
  17. Subject: This is the Subject!
  18. From: Mailgun Testing <test@test.mailgun.com>
  19. To: test@test.mailgun.com
  20. Message-Id: <20130610095049.30790.4334@test.mailgun.com>
  21. Content-Transfer-Encoding: 7bit
  22. X-Mailgun-Sid: WyIxYTdhMyIsICJmaXplcmtoYW5AcXVhZG1zLmluIiwgImExOWQiXQ==
  23. Date: Mon, 10 Jun 2013 09:50:58 +0000
  24. Sender: test@test.mailgun.com
  25. Mailgun is testing!";
  26. $envelopeFields = array('to' => 'test@test.mailgun.org');
  27. $result = $this->client->sendMessage("test.mailgun.org", $envelopeFields, $customMime);
  28. $this->assertEquals("test.mailgun.org/messages.mime", $result->http_endpoint_url);
  29. }
  30. public function testSendMessage()
  31. {
  32. $message = array('to' => 'test@test.mailgun.org',
  33. 'from' => 'sender@test.mailgun.org',
  34. 'subject' => 'This is my test subject',
  35. 'text' => 'Testing!'
  36. );
  37. $result = $this->client->sendMessage("test.mailgun.org", $message);
  38. $this->assertEquals("test.mailgun.org/messages", $result->http_endpoint_url);
  39. }
  40. }