Fixed missing IDs for batch message recipients. Closes #15.

This commit is contained in:
Travis Swientek 2013-10-07 13:53:23 -07:00
parent 75ffd38b1d
commit fc9685182b
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']);
}
}
?>