mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-22 04:26:02 +03:00
Revise domain creation assertions and add tests
Based on feedback from @DavidGarciaCat.
This commit is contained in:
parent
c9bbf8e45f
commit
2db0619d8a
@ -90,12 +90,11 @@ class Domain extends HttpApi
|
||||
|
||||
if (!empty($smtpPass)) {
|
||||
Assert::stringNotEmpty($smtpPass);
|
||||
Assert::lengthBetween($smtpPass, 5, 32, 'SMTP password must be between 5 and 32 characters.');
|
||||
|
||||
$params['smtp_password'] = $smtpPass;
|
||||
}
|
||||
|
||||
if (null !== $spamAction) {
|
||||
if (!empty($spamAction)) {
|
||||
// TODO(sean.johnson): Extended spam filter input validation.
|
||||
Assert::stringNotEmpty($spamAction);
|
||||
|
||||
|
@ -85,6 +85,20 @@ JSON
|
||||
}
|
||||
|
||||
public function testCreateWithPassword()
|
||||
{
|
||||
$this->setRequestMethod('POST');
|
||||
$this->setRequestUri('/v3/domains');
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
$api = $this->getApiInstance();
|
||||
$api->create('example.com', 'foo');
|
||||
}
|
||||
|
||||
public function testCreateWithPasswordSpamAction()
|
||||
{
|
||||
$this->setRequestMethod('POST');
|
||||
$this->setRequestUri('/v3/domains');
|
||||
@ -95,6 +109,22 @@ JSON
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
$api = $this->getApiInstance();
|
||||
$api->create('example.com', 'foo', 'bar');
|
||||
}
|
||||
|
||||
public function testCreateWithPasswordSpamActionWildcard()
|
||||
{
|
||||
$this->setRequestMethod('POST');
|
||||
$this->setRequestUri('/v3/domains');
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'spam_action' => 'bar',
|
||||
'wildcard' => 'true',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
$api = $this->getApiInstance();
|
||||
$api->create('example.com', 'foo', 'bar', true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user