Pool id tests (#793)

* Add the `pool_id` parameter to Domain::create()

* Formatting

* Added tests

* Added missing comma

Co-authored-by: Roy Hill-Percival <github@royhp.com>
This commit is contained in:
Pawel Wasiluk 2021-10-05 09:44:50 +02:00 committed by GitHub
parent d987c3e5e2
commit 6853b03247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -84,10 +84,11 @@ class Domain extends HttpApi
* @param bool $wildcard domain will accept email for subdomains * @param bool $wildcard domain will accept email for subdomains
* @param bool $forceDkimAuthority force DKIM authority * @param bool $forceDkimAuthority force DKIM authority
* @param string[] $ips an array of ips to be assigned to the domain * @param string[] $ips an array of ips to be assigned to the domain
* @param ?string $pool_id pool id to assign to the domain
* *
* @return CreateResponse|array|ResponseInterface * @return CreateResponse|array|ResponseInterface
*/ */
public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = null) public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = null, ?string $pool_id = null)
{ {
Assert::stringNotEmpty($domain); Assert::stringNotEmpty($domain);
@ -125,6 +126,12 @@ class Domain extends HttpApi
$params['ips'] = join(',', $ips); $params['ips'] = join(',', $ips);
} }
if (null !== $pool_id) {
Assert::stringNotEmpty($pool_id);
$params['pool_id'] = $pool_id;
}
$response = $this->httpPost('/v3/domains', $params); $response = $this->httpPost('/v3/domains', $params);
return $this->hydrateResponse($response, CreateResponse::class); return $this->hydrateResponse($response, CreateResponse::class);

View File

@ -103,6 +103,21 @@ JSON
$api->create('example.com', 'foo'); $api->create('example.com', 'foo');
} }
public function testCreateWithPoolId()
{
$this->setRequestMethod('POST');
$this->setRequestUri('/v3/domains');
$this->setRequestBody([
'name' => 'example.com',
'smtp_password' => 'foo',
'pool_id' => '123',
]);
$this->setHydrateClass(CreateResponse::class);
$api = $this->getApiInstance();
$api->create('example.com', 'foo', null, null, null, null, '123');
}
public function testCreateWithPasswordSpamAction() public function testCreateWithPasswordSpamAction()
{ {
$this->setRequestMethod('POST'); $this->setRequestMethod('POST');