mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-25 14:26:04 +03:00
Fixed integration tests (#233)
* Fixed integration tests * Update integration tests * cs
This commit is contained in:
parent
8c2ffbfd3f
commit
61a019ad67
@ -4,7 +4,7 @@
|
|||||||
* Copyright (C) 2013-2016 Mailgun
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
*
|
*
|
||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Api;
|
namespace Mailgun\Api;
|
||||||
@ -95,7 +95,7 @@ class Domain extends HttpApi
|
|||||||
'wildcard' => $wildcard,
|
'wildcard' => $wildcard,
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->httpPostMultipart('/v3/domains', $params);
|
$response = $this->httpPost('/v3/domains', $params);
|
||||||
|
|
||||||
return $this->safeDeserialize($response, CreateResponse::class);
|
return $this->safeDeserialize($response, CreateResponse::class);
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ class Domain extends HttpApi
|
|||||||
$params['skip_verification'] = $noVerify ? 'true' : 'false';
|
$params['skip_verification'] = $noVerify ? 'true' : 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->httpPutMultipart(sprintf('/v3/domains/%s/connection', $domain), $params);
|
$response = $this->httpPut(sprintf('/v3/domains/%s/connection', $domain), $params);
|
||||||
|
|
||||||
return $this->deserializer->deserialize($response, UpdateConnectionResponse::class);
|
return $this->deserializer->deserialize($response, UpdateConnectionResponse::class);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Copyright (C) 2013-2016 Mailgun
|
* Copyright (C) 2013-2016 Mailgun
|
||||||
*
|
*
|
||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Mailgun\Tests\Integration;
|
namespace Mailgun\Tests\Integration;
|
||||||
@ -40,7 +40,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$domainList = $mg->getDomainApi()->index();
|
$domainList = $mg->domains()->index();
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach ($domainList->getDomains() as $domain) {
|
foreach ($domainList->getDomains() as $domain) {
|
||||||
if ($domain->getName() === $this->testDomain) {
|
if ($domain->getName() === $this->testDomain) {
|
||||||
@ -60,7 +60,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$domain = $mg->getDomainApi()->show($this->testDomain);
|
$domain = $mg->domains()->show($this->testDomain);
|
||||||
$this->assertNotNull($domain);
|
$this->assertNotNull($domain);
|
||||||
$this->assertNotNull($domain->getDomain());
|
$this->assertNotNull($domain->getDomain());
|
||||||
$this->assertNotNull($domain->getInboundDNSRecords());
|
$this->assertNotNull($domain->getInboundDNSRecords());
|
||||||
@ -75,7 +75,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->delete('example.notareal.tld');
|
$ret = $mg->domains()->delete('example.notareal.tld');
|
||||||
$this->assertNotNull($ret);
|
$this->assertNotNull($ret);
|
||||||
$this->assertInstanceOf(DeleteResponse::class, $ret);
|
$this->assertInstanceOf(DeleteResponse::class, $ret);
|
||||||
$this->assertEquals('Domain not found', $ret->getMessage());
|
$this->assertEquals('Domain not found', $ret->getMessage());
|
||||||
@ -89,7 +89,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$domain = $mg->getDomainApi()->create(
|
$domain = $mg->domains()->create(
|
||||||
'example.notareal.tld', // domain name
|
'example.notareal.tld', // domain name
|
||||||
'exampleOrgSmtpPassword12', // smtp password
|
'exampleOrgSmtpPassword12', // smtp password
|
||||||
'tag', // default spam action
|
'tag', // default spam action
|
||||||
@ -109,7 +109,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$domain = $mg->getDomainApi()->create(
|
$domain = $mg->domains()->create(
|
||||||
'example.notareal.tld', // domain name
|
'example.notareal.tld', // domain name
|
||||||
'exampleOrgSmtpPassword12', // smtp password
|
'exampleOrgSmtpPassword12', // smtp password
|
||||||
'tag', // default spam action
|
'tag', // default spam action
|
||||||
@ -127,7 +127,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->delete('example.notareal.tld');
|
$ret = $mg->domains()->delete('example.notareal.tld');
|
||||||
$this->assertNotNull($ret);
|
$this->assertNotNull($ret);
|
||||||
$this->assertInstanceOf(DeleteResponse::class, $ret);
|
$this->assertInstanceOf(DeleteResponse::class, $ret);
|
||||||
$this->assertEquals('Domain has been deleted', $ret->getMessage());
|
$this->assertEquals('Domain has been deleted', $ret->getMessage());
|
||||||
@ -141,7 +141,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->createCredential(
|
$ret = $mg->domains()->createCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
'user-test@'.$this->testDomain,
|
'user-test@'.$this->testDomain,
|
||||||
'Password.01!'
|
'Password.01!'
|
||||||
@ -155,13 +155,13 @@ class DomainApiTest extends TestCase
|
|||||||
* Performs `POST /v3/domains/<domain>/credentials` to attempt to add an invalid
|
* Performs `POST /v3/domains/<domain>/credentials` to attempt to add an invalid
|
||||||
* credential pair.
|
* credential pair.
|
||||||
*
|
*
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException \Mailgun\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCreateCredentialBadPasswordLong()
|
public function testCreateCredentialBadPasswordLong()
|
||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->createCredential(
|
$ret = $mg->domains()->createCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
'user-test',
|
'user-test',
|
||||||
'ExtremelyLongPasswordThatCertainlyWillNotBeAccepted'
|
'ExtremelyLongPasswordThatCertainlyWillNotBeAccepted'
|
||||||
@ -174,13 +174,13 @@ class DomainApiTest extends TestCase
|
|||||||
* Performs `POST /v3/domains/<domain>/credentials` to attempt to add an invalid
|
* Performs `POST /v3/domains/<domain>/credentials` to attempt to add an invalid
|
||||||
* credential pair.
|
* credential pair.
|
||||||
*
|
*
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException \Mailgun\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCreateCredentialBadPasswordShort()
|
public function testCreateCredentialBadPasswordShort()
|
||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->createCredential(
|
$ret = $mg->domains()->createCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
'user-test',
|
'user-test',
|
||||||
'no'
|
'no'
|
||||||
@ -198,7 +198,7 @@ class DomainApiTest extends TestCase
|
|||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->credentials($this->testDomain);
|
$ret = $mg->domains()->credentials($this->testDomain);
|
||||||
$this->assertNotNull($ret);
|
$this->assertNotNull($ret);
|
||||||
$this->assertInstanceOf(CredentialResponse::class, $ret);
|
$this->assertInstanceOf(CredentialResponse::class, $ret);
|
||||||
$this->assertContainsOnlyInstancesOf(CredentialResponseItem::class, $ret->getCredentials());
|
$this->assertContainsOnlyInstancesOf(CredentialResponseItem::class, $ret->getCredentials());
|
||||||
@ -219,7 +219,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->credentials('mailgun.org');
|
$ret = $mg->domains()->credentials('mailgun.org');
|
||||||
$this->assertNotNull($ret);
|
$this->assertNotNull($ret);
|
||||||
$this->assertInstanceOf(ErrorResponse::class, $ret);
|
$this->assertInstanceOf(ErrorResponse::class, $ret);
|
||||||
$this->assertEquals('Domain not found: mailgun.org', $ret->getMessage());
|
$this->assertEquals('Domain not found: mailgun.org', $ret->getMessage());
|
||||||
@ -235,7 +235,7 @@ class DomainApiTest extends TestCase
|
|||||||
|
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->updateCredential(
|
$ret = $mg->domains()->updateCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
$login,
|
$login,
|
||||||
'Password..02!'
|
'Password..02!'
|
||||||
@ -248,7 +248,7 @@ class DomainApiTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Performs `PUT /v3/domains/<domain>/credentials/<login>` with a bad password.
|
* Performs `PUT /v3/domains/<domain>/credentials/<login>` with a bad password.
|
||||||
*
|
*
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException \Mailgun\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testUpdateCredentialBadPasswordLong()
|
public function testUpdateCredentialBadPasswordLong()
|
||||||
{
|
{
|
||||||
@ -256,7 +256,7 @@ class DomainApiTest extends TestCase
|
|||||||
|
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->updateCredential(
|
$ret = $mg->domains()->updateCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
$login,
|
$login,
|
||||||
'ThisIsAnExtremelyLongPasswordThatSurelyWontBeAccepted'
|
'ThisIsAnExtremelyLongPasswordThatSurelyWontBeAccepted'
|
||||||
@ -267,7 +267,7 @@ class DomainApiTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Performs `PUT /v3/domains/<domain>/credentials/<login>` with a bad password.
|
* Performs `PUT /v3/domains/<domain>/credentials/<login>` with a bad password.
|
||||||
*
|
*
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException \Mailgun\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testUpdateCredentialBadPasswordShort()
|
public function testUpdateCredentialBadPasswordShort()
|
||||||
{
|
{
|
||||||
@ -275,7 +275,7 @@ class DomainApiTest extends TestCase
|
|||||||
|
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->updateCredential(
|
$ret = $mg->domains()->updateCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
$login,
|
$login,
|
||||||
'no'
|
'no'
|
||||||
@ -293,7 +293,7 @@ class DomainApiTest extends TestCase
|
|||||||
|
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->deleteCredential(
|
$ret = $mg->domains()->deleteCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
$login
|
$login
|
||||||
);
|
);
|
||||||
@ -313,7 +313,7 @@ class DomainApiTest extends TestCase
|
|||||||
|
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->deleteCredential(
|
$ret = $mg->domains()->deleteCredential(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
$login
|
$login
|
||||||
);
|
);
|
||||||
@ -329,7 +329,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->connection($this->testDomain);
|
$ret = $mg->domains()->connection($this->testDomain);
|
||||||
$this->assertNotNull($ret);
|
$this->assertNotNull($ret);
|
||||||
$this->assertInstanceOf(ConnectionResponse::class, $ret);
|
$this->assertInstanceOf(ConnectionResponse::class, $ret);
|
||||||
$this->assertTrue(is_bool($ret->getSkipVerification()));
|
$this->assertTrue(is_bool($ret->getSkipVerification()));
|
||||||
@ -343,7 +343,7 @@ class DomainApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mg = $this->getMailgunClient();
|
$mg = $this->getMailgunClient();
|
||||||
|
|
||||||
$ret = $mg->getDomainApi()->updateConnection(
|
$ret = $mg->domains()->updateConnection(
|
||||||
$this->testDomain,
|
$this->testDomain,
|
||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user