Merge pull request #16 from travelton/BatchMessageFixing

Fixed missing IDs for batch message recipients. Closes #15.
This commit is contained in:
Travis Swientek 2013-10-07 17:00:54 -07:00
commit 70cd750ace
2 changed files with 13 additions and 1 deletions

View File

@ -36,7 +36,9 @@ class BatchMessage extends MessageBuilder{
}
$this->addRecipient("to", $address, $variables);
$attributes["id"] = $this->toRecipientCount;
if(!array_key_exists("id", $variables)){
$variables['id'] = $this->toRecipientCount;
}
$this->batchRecipientAttributes["$address"] = $variables;
}

View File

@ -59,6 +59,16 @@ class BatchMessageTest extends \Mailgun\Tests\MailgunTestCase{
$property->setAccessible(true);
$this->assertEquals(1, $property->getValue($message));
}
public function testDefaultIDInVariables() {
$message = $this->client->BatchMessage($this->sampleDomain);
$message->addToRecipient("test-user@samples.mailgun.org", array("first" => "Test", "last" => "User"));
$reflectionClass = new \ReflectionClass(get_class($message));
$property = $reflectionClass->getProperty('batchRecipientAttributes');
$property->setAccessible(True);
$propertyValue = $property->getValue($message);
$this->assertEquals(1, $propertyValue['test-user@samples.mailgun.org']['id']);
}
}
?>