From 5d7daeeeca1108e9cd10a8a94e029026266c7397 Mon Sep 17 00:00:00 2001 From: Travis Swientek Date: Fri, 11 Oct 2013 17:31:04 -0700 Subject: [PATCH] Added method to return all message ids after a BatchMessage operation. --- src/Mailgun/Messages/BatchMessage.php | 5 ++++- tests/Mailgun/Tests/Messages/BatchMessageTest.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Mailgun/Messages/BatchMessage.php b/src/Mailgun/Messages/BatchMessage.php index 3152f27..5a022a5 100644 --- a/src/Mailgun/Messages/BatchMessage.php +++ b/src/Mailgun/Messages/BatchMessage.php @@ -84,12 +84,15 @@ class BatchMessage extends MessageBuilder{ $this->counters['recipients']['bcc'] = 0; unset($this->message["to"]); array_push($this->messageIds, $response->http_response_body->id); - return $this->messageIds; } } public function finalize(){ return $this->sendMessage(); } + + public function getMessageIds(){ + return $this->messageIds; + } } ?> \ No newline at end of file diff --git a/tests/Mailgun/Tests/Messages/BatchMessageTest.php b/tests/Mailgun/Tests/Messages/BatchMessageTest.php index b67a45a..4f175c0 100644 --- a/tests/Mailgun/Tests/Messages/BatchMessageTest.php +++ b/tests/Mailgun/Tests/Messages/BatchMessageTest.php @@ -105,6 +105,16 @@ class BatchMessageTest extends \Mailgun\Tests\MailgunTestCase{ $propertyValue = $property->getValue($message); $this->assertEquals(1, $propertyValue['test-user@samples.mailgun.org']['id']); } + public function testgetMessageIds() { + $message = $this->client->BatchMessage($this->sampleDomain); + $message->addToRecipient("test-user@samples.mailgun.org", array("first" => "Test", "last" => "User")); + $message->setFromAddress("samples@mailgun.org", array("first" => "Test", "last" => "User")); + $message->setSubject("This is the subject of the message!"); + $message->setTextBody("This is the text body of the message!"); + $message->finalize(); + + $this->assertEquals(array("1234"), $message->getMessageIds()); + } } ?>