From 61a019ad672d4e9e62f8a44402f7fccd8f6a4383 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 24 Nov 2016 09:59:05 +0100 Subject: [PATCH] Fixed integration tests (#233) * Fixed integration tests * Update integration tests * cs --- src/Mailgun/Api/Domain.php | 6 ++-- tests/Integration/DomainApiTest.php | 46 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Mailgun/Api/Domain.php b/src/Mailgun/Api/Domain.php index c79960d..bea087c 100644 --- a/src/Mailgun/Api/Domain.php +++ b/src/Mailgun/Api/Domain.php @@ -4,7 +4,7 @@ * Copyright (C) 2013-2016 Mailgun * * 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; @@ -95,7 +95,7 @@ class Domain extends HttpApi 'wildcard' => $wildcard, ]; - $response = $this->httpPostMultipart('/v3/domains', $params); + $response = $this->httpPost('/v3/domains', $params); return $this->safeDeserialize($response, CreateResponse::class); } @@ -259,7 +259,7 @@ class Domain extends HttpApi $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); } diff --git a/tests/Integration/DomainApiTest.php b/tests/Integration/DomainApiTest.php index 0af8d2a..e577ca1 100644 --- a/tests/Integration/DomainApiTest.php +++ b/tests/Integration/DomainApiTest.php @@ -4,7 +4,7 @@ * Copyright (C) 2013-2016 Mailgun * * 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; @@ -40,7 +40,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $domainList = $mg->getDomainApi()->index(); + $domainList = $mg->domains()->index(); $found = false; foreach ($domainList->getDomains() as $domain) { if ($domain->getName() === $this->testDomain) { @@ -60,7 +60,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $domain = $mg->getDomainApi()->show($this->testDomain); + $domain = $mg->domains()->show($this->testDomain); $this->assertNotNull($domain); $this->assertNotNull($domain->getDomain()); $this->assertNotNull($domain->getInboundDNSRecords()); @@ -75,7 +75,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->delete('example.notareal.tld'); + $ret = $mg->domains()->delete('example.notareal.tld'); $this->assertNotNull($ret); $this->assertInstanceOf(DeleteResponse::class, $ret); $this->assertEquals('Domain not found', $ret->getMessage()); @@ -89,7 +89,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $domain = $mg->getDomainApi()->create( + $domain = $mg->domains()->create( 'example.notareal.tld', // domain name 'exampleOrgSmtpPassword12', // smtp password 'tag', // default spam action @@ -109,7 +109,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $domain = $mg->getDomainApi()->create( + $domain = $mg->domains()->create( 'example.notareal.tld', // domain name 'exampleOrgSmtpPassword12', // smtp password 'tag', // default spam action @@ -127,7 +127,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->delete('example.notareal.tld'); + $ret = $mg->domains()->delete('example.notareal.tld'); $this->assertNotNull($ret); $this->assertInstanceOf(DeleteResponse::class, $ret); $this->assertEquals('Domain has been deleted', $ret->getMessage()); @@ -141,7 +141,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->createCredential( + $ret = $mg->domains()->createCredential( $this->testDomain, 'user-test@'.$this->testDomain, 'Password.01!' @@ -155,13 +155,13 @@ class DomainApiTest extends TestCase * Performs `POST /v3/domains//credentials` to attempt to add an invalid * credential pair. * - * @expectedException InvalidArgumentException + * @expectedException \Mailgun\Exception\InvalidArgumentException */ public function testCreateCredentialBadPasswordLong() { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->createCredential( + $ret = $mg->domains()->createCredential( $this->testDomain, 'user-test', 'ExtremelyLongPasswordThatCertainlyWillNotBeAccepted' @@ -174,13 +174,13 @@ class DomainApiTest extends TestCase * Performs `POST /v3/domains//credentials` to attempt to add an invalid * credential pair. * - * @expectedException InvalidArgumentException + * @expectedException \Mailgun\Exception\InvalidArgumentException */ public function testCreateCredentialBadPasswordShort() { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->createCredential( + $ret = $mg->domains()->createCredential( $this->testDomain, 'user-test', 'no' @@ -198,7 +198,7 @@ class DomainApiTest extends TestCase $found = false; - $ret = $mg->getDomainApi()->credentials($this->testDomain); + $ret = $mg->domains()->credentials($this->testDomain); $this->assertNotNull($ret); $this->assertInstanceOf(CredentialResponse::class, $ret); $this->assertContainsOnlyInstancesOf(CredentialResponseItem::class, $ret->getCredentials()); @@ -219,7 +219,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->credentials('mailgun.org'); + $ret = $mg->domains()->credentials('mailgun.org'); $this->assertNotNull($ret); $this->assertInstanceOf(ErrorResponse::class, $ret); $this->assertEquals('Domain not found: mailgun.org', $ret->getMessage()); @@ -235,7 +235,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->updateCredential( + $ret = $mg->domains()->updateCredential( $this->testDomain, $login, 'Password..02!' @@ -248,7 +248,7 @@ class DomainApiTest extends TestCase /** * Performs `PUT /v3/domains//credentials/` with a bad password. * - * @expectedException InvalidArgumentException + * @expectedException \Mailgun\Exception\InvalidArgumentException */ public function testUpdateCredentialBadPasswordLong() { @@ -256,7 +256,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->updateCredential( + $ret = $mg->domains()->updateCredential( $this->testDomain, $login, 'ThisIsAnExtremelyLongPasswordThatSurelyWontBeAccepted' @@ -267,7 +267,7 @@ class DomainApiTest extends TestCase /** * Performs `PUT /v3/domains//credentials/` with a bad password. * - * @expectedException InvalidArgumentException + * @expectedException \Mailgun\Exception\InvalidArgumentException */ public function testUpdateCredentialBadPasswordShort() { @@ -275,7 +275,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->updateCredential( + $ret = $mg->domains()->updateCredential( $this->testDomain, $login, 'no' @@ -293,7 +293,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->deleteCredential( + $ret = $mg->domains()->deleteCredential( $this->testDomain, $login ); @@ -313,7 +313,7 @@ class DomainApiTest extends TestCase $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->deleteCredential( + $ret = $mg->domains()->deleteCredential( $this->testDomain, $login ); @@ -329,7 +329,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->connection($this->testDomain); + $ret = $mg->domains()->connection($this->testDomain); $this->assertNotNull($ret); $this->assertInstanceOf(ConnectionResponse::class, $ret); $this->assertTrue(is_bool($ret->getSkipVerification())); @@ -343,7 +343,7 @@ class DomainApiTest extends TestCase { $mg = $this->getMailgunClient(); - $ret = $mg->getDomainApi()->updateConnection( + $ret = $mg->domains()->updateConnection( $this->testDomain, true, false