mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-23 04:56:02 +03:00
Merge pull request #157 from Nyholm/issue-150
Make sure we use proper POST data arrays
This commit is contained in:
commit
54b7f851b8
@ -133,9 +133,10 @@ class RestClient
|
|||||||
$postDataMultipart = [];
|
$postDataMultipart = [];
|
||||||
foreach ($postData as $key => $value) {
|
foreach ($postData as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
|
$index = 0;
|
||||||
foreach ($value as $subValue) {
|
foreach ($value as $subValue) {
|
||||||
$postDataMultipart[] = [
|
$postDataMultipart[] = [
|
||||||
'name' => $key,
|
'name' => sprintf('%s[%d]', $key, $index++),
|
||||||
'contents' => $subValue,
|
'contents' => $subValue,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -10,18 +10,13 @@ class InlineFileTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
public function testSimpleExample()
|
public function testSimpleExample()
|
||||||
{
|
{
|
||||||
// Create a Closure that validates the $files parameter to RestClient::send()
|
|
||||||
$fileValidator = function($files) {
|
$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 = [
|
$fileNames = [
|
||||||
['name'=>'inline[0]', 'filename'=>'foo.png'],
|
['name'=>'inline[0]', 'filename'=>'foo.png'],
|
||||||
['name'=>'inline[1]', 'filename'=>'bar.png']
|
['name'=>'inline[1]', 'filename'=>'bar.png']
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Make sure that both files exists
|
||||||
foreach ($fileNames as $idx => $fileName) {
|
foreach ($fileNames as $idx => $fileName) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if ($file['name'] === $fileName['name'] && $file['filename'] === $fileName['filename']) {
|
if ($file['name'] === $fileName['name'] && $file['filename'] === $fileName['filename']) {
|
||||||
|
@ -26,7 +26,16 @@ class NoSamePostNameTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$builder = $mailgun->MessageBuilder();
|
$builder = $mailgun->MessageBuilder();
|
||||||
$builder->setFromAddress("bob@example.com");
|
$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->setSubject("Foo");
|
||||||
$builder->setTextBody("Bar");
|
$builder->setTextBody("Bar");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user