diff --git a/src/Mailgun/Connection/RestClient.php b/src/Mailgun/Connection/RestClient.php index af1dfe3..849b981 100644 --- a/src/Mailgun/Connection/RestClient.php +++ b/src/Mailgun/Connection/RestClient.php @@ -133,9 +133,10 @@ class RestClient $postDataMultipart = []; foreach ($postData as $key => $value) { if (is_array($value)) { + $index = 0; foreach ($value as $subValue) { $postDataMultipart[] = [ - 'name' => $key, + 'name' => sprintf('%s[%d]', $key, $index++), 'contents' => $subValue, ]; } diff --git a/tests/Functional/InlineFileTest.php b/tests/Functional/InlineFileTest.php index 0942f27..91c9003 100644 --- a/tests/Functional/InlineFileTest.php +++ b/tests/Functional/InlineFileTest.php @@ -10,18 +10,13 @@ class InlineFileTest extends \PHPUnit_Framework_TestCase { public function testSimpleExample() { - // Create a Closure that validates the $files parameter to RestClient::send() $fileValidator = function($files) { - // Validate standard params - $this->assertContains(['name'=>'from', 'contents'=>'bob@example.com'], $files); - $this->assertContains(['name'=>'to', 'contents'=>'alice@example.com'], $files); - $this->assertContains(['name'=>'subject', 'contents'=>'Foo'], $files); - $this->assertContains(['name'=>'text', 'contents'=>'Bar'], $files); - $fileNames = [ ['name'=>'inline[0]', 'filename'=>'foo.png'], ['name'=>'inline[1]', 'filename'=>'bar.png'] ]; + + // Make sure that both files exists foreach ($fileNames as $idx => $fileName) { foreach ($files as $file) { if ($file['name'] === $fileName['name'] && $file['filename'] === $fileName['filename']) { diff --git a/tests/Functional/NoSamePostNameTest.php b/tests/Functional/NoSamePostNameTest.php index 0f346ff..2e6678c 100644 --- a/tests/Functional/NoSamePostNameTest.php +++ b/tests/Functional/NoSamePostNameTest.php @@ -26,7 +26,16 @@ class NoSamePostNameTest extends \PHPUnit_Framework_TestCase $builder = $mailgun->MessageBuilder(); $builder->setFromAddress("bob@example.com"); - $builder->addToRecipient("alice@example.com"); + $builder->addToRecipient("to1@example.com"); + $builder->addToRecipient("to2@example.com"); + $builder->addCcRecipient("cc1@example.com"); + $builder->addCcRecipient("cc2@example.com"); + $builder->addBccRecipient("bcc1@example.com"); + $builder->addBccRecipient("bcc2@example.com"); + $builder->addCustomParameter('foo', 'bar'); + $builder->addCustomParameter('foo', 'baz'); + $builder->addCampaignId('campaign0'); + $builder->addCampaignId('campaign1'); $builder->setSubject("Foo"); $builder->setTextBody("Bar");