mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-21 15:23:15 +03:00
Fixed issues (#829)
* Fixed issues - BatchMessage generates "invalid" JSON for recipients with an empty set of recipient-variables - Use null coalescing operator in IndexResponse.php * Fix warning from php-cs-fixer
This commit is contained in:
parent
2395e5d232
commit
c04197362b
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,4 +7,4 @@ phpunit.xml
|
|||||||
modd.conf
|
modd.conf
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
.phpunit.result.cache
|
.idea
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
|
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
|
||||||
|
|
||||||
|
## 3.5.1
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Error with empty array for param recipient-variables. Fix was suggested by @deviarte
|
||||||
|
- Use null coalescing operator in IndexResponse.php when. Fix proposed by @TWithers
|
||||||
|
|
||||||
## 3.5.0
|
## 3.5.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit bootstrap="vendor/autoload.php"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||||
colors="true"
|
<coverage processUncoveredFiles="true">
|
||||||
processIsolation="false"
|
<include>
|
||||||
stopOnFailure="false"
|
<directory suffix=".php">src</directory>
|
||||||
convertErrorsToExceptions="true"
|
</include>
|
||||||
convertNoticesToExceptions="true"
|
</coverage>
|
||||||
convertWarningsToExceptions="true">
|
<testsuites>
|
||||||
|
<testsuite name="Mailgun test suite">
|
||||||
<testsuites>
|
<directory>tests</directory>
|
||||||
<testsuite name="Mailgun test suite">
|
</testsuite>
|
||||||
<directory>tests</directory>
|
</testsuites>
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
|
|
||||||
<filter>
|
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
|
||||||
<directory suffix=".php">src</directory>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
21
phpunit.xml.dist.bak
Normal file
21
phpunit.xml.dist.bak
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
processIsolation="false"
|
||||||
|
stopOnFailure="false"
|
||||||
|
convertErrorsToExceptions="true"
|
||||||
|
convertNoticesToExceptions="true"
|
||||||
|
convertWarningsToExceptions="true">
|
||||||
|
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Mailgun test suite">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">src</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
@ -118,7 +118,7 @@ class BatchMessage extends MessageBuilder
|
|||||||
throw MissingRequiredParameter::create('text", "html" or "template');
|
throw MissingRequiredParameter::create('text", "html" or "template');
|
||||||
}
|
}
|
||||||
|
|
||||||
$message['recipient-variables'] = json_encode($this->batchRecipientAttributes);
|
$message['recipient-variables'] = json_encode($this->batchRecipientAttributes, JSON_FORCE_OBJECT);
|
||||||
$response = $this->api->send($this->domain, $message);
|
$response = $this->api->send($this->domain, $message);
|
||||||
|
|
||||||
$this->batchRecipientAttributes = [];
|
$this->batchRecipientAttributes = [];
|
||||||
|
@ -42,7 +42,7 @@ final class IndexResponse implements ApiResponse
|
|||||||
$model = new self();
|
$model = new self();
|
||||||
$model->items = $data['items'];
|
$model->items = $data['items'];
|
||||||
$model->totalCount = $data['total_count'] ?? 0;
|
$model->totalCount = $data['total_count'] ?? 0;
|
||||||
$model->assignableToPools = $data['assignable_to_pools'];
|
$model->assignableToPools = $data['assignable_to_pools'] ?? [];
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
@ -181,4 +181,19 @@ class BatchMessageTest extends MailgunTestCase
|
|||||||
$this->expectException(MissingRequiredParameter::class);
|
$this->expectException(MissingRequiredParameter::class);
|
||||||
$this->batchMessage->finalize();
|
$this->batchMessage->finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyRecipientForBatchMessage(): void
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'from' => 'BATCH <example@gmail.com>',
|
||||||
|
'to' => ['example@gmail.com'],
|
||||||
|
'subject' => 'Hey %recipient.first%',
|
||||||
|
'text' => 'If you wish to unsubscribe, click http://example.com/unsubscribe/%recipient.id%',
|
||||||
|
'recipient-variables' => [],
|
||||||
|
];
|
||||||
|
$this->batchMessage->setMessage($params);
|
||||||
|
$this->batchMessage->finalize();
|
||||||
|
$message = NSA::getProperty($this->batchMessage, 'message');
|
||||||
|
$this->assertEquals([], $message['recipient-variables']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user