From 1522523873f0267ce49b42e7d72aa88dcb8820f6 Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Tue, 7 Jan 2020 16:49:55 +0100 Subject: [PATCH 1/6] Update PHPUnit to 8.x.x --- .gitignore | 1 + composer.json | 2 +- tests/integration/BaseTest.php | 13 ++++++------- tests/integration/HttpClientTest.php | 6 ++---- tests/integration/balance/BalanceTest.php | 3 ++- tests/integration/chat/ChatTest.php | 2 +- tests/integration/contacts/ContactTest.php | 2 +- .../conversation/ConversationMessageTest.php | 2 +- tests/integration/conversation/ConversationTest.php | 2 +- .../conversation/ConversationWebhookTest.php | 2 +- tests/integration/groups/GroupTest.php | 2 +- tests/integration/hlr/HlrTest.php | 2 +- tests/integration/lookup/LookupTest.php | 2 +- tests/integration/messages/MessagesTest.php | 2 +- tests/integration/partneraccount/AccountTest.php | 2 +- tests/integration/verify/VerifyTest.php | 2 +- tests/integration/voice/VoiceTest.php | 2 +- .../integration/voicemessages/VoiceMessagesTest.php | 2 +- tests/unit/RequestValidatorTest.php | 3 ++- tests/unit/SignedRequestTest.php | 3 ++- 20 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 1f2bccf1..c3d69fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock composer.phar .DS_Store .idea/ +.phpunit.* diff --git a/composer.json b/composer.json index b32ed4e8..ab861043 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "symfony/polyfill-php56": "^1.10" }, "require-dev": { - "phpunit/phpunit": "^4.8.25" + "phpunit/phpunit": "^8" }, "autoload": { "psr-4": { diff --git a/tests/integration/BaseTest.php b/tests/integration/BaseTest.php index fcb09836..808cc1bc 100644 --- a/tests/integration/BaseTest.php +++ b/tests/integration/BaseTest.php @@ -1,11 +1,8 @@ =6. See: https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-6.0.0 -if (!class_exists('PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { - class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); -} -class BaseTest extends PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class BaseTest extends TestCase { /** @var \MessageBird\Client */ protected $client; @@ -13,7 +10,7 @@ class BaseTest extends PHPUnit_Framework_TestCase /** @var PHPUnit_Framework_MockObject_MockObject */ protected $mockClient; - public function setUp() + protected function setUp(): void { $this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(array("fake.messagebird.dev"))->getMock(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); @@ -43,6 +40,8 @@ public function testClientConstructor() $this->assertInstanceOf('MessageBird\Resources\Chat\Platform', $MessageBird->chatPlatforms); $this->assertInstanceOf('MessageBird\Resources\Chat\Channel', $MessageBird->chatChannels); $this->assertInstanceOf('MessageBird\Resources\Chat\Contact', $MessageBird->chatContacts); + $this->assertInstanceOf('MessageBird\Resources\AvailableNumbers', $MessageBird->availableNumbers); + $this->assertInstanceOf('MessageBird\Resources\PurchasedNumbers', $MessageBird->purchasedNumbers); } diff --git a/tests/integration/HttpClientTest.php b/tests/integration/HttpClientTest.php index 566ca9af..0db94230 100644 --- a/tests/integration/HttpClientTest.php +++ b/tests/integration/HttpClientTest.php @@ -16,12 +16,10 @@ public function testHttpClient() $this->assertSame(Client::ENDPOINT.'/a?b=1', $url); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp #^Timeout must be an int > 0, got "integer 0".$# - */ public function testHttpClientInvalidTimeout() { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessageRegExp('/^Timeout must be an int > 0, got "integer 0".$/'); new HttpClient(Client::ENDPOINT, 0); } diff --git a/tests/integration/balance/BalanceTest.php b/tests/integration/balance/BalanceTest.php index fe2e670c..14fb813e 100644 --- a/tests/integration/balance/BalanceTest.php +++ b/tests/integration/balance/BalanceTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); @@ -12,6 +12,7 @@ public function setUp() */ public function testReadBalance() { + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'balance', null, null); $this->client->balance->read(); } diff --git a/tests/integration/chat/ChatTest.php b/tests/integration/chat/ChatTest.php index cfc5fba6..2cccb213 100644 --- a/tests/integration/chat/ChatTest.php +++ b/tests/integration/chat/ChatTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/contacts/ContactTest.php b/tests/integration/contacts/ContactTest.php index 3104d624..4eebb3df 100644 --- a/tests/integration/contacts/ContactTest.php +++ b/tests/integration/contacts/ContactTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/conversation/ConversationMessageTest.php b/tests/integration/conversation/ConversationMessageTest.php index ca8d235c..c6d9e468 100644 --- a/tests/integration/conversation/ConversationMessageTest.php +++ b/tests/integration/conversation/ConversationMessageTest.php @@ -46,7 +46,7 @@ class ConversationMessageTest extends BaseTest "type": "video" }'; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/conversation/ConversationTest.php b/tests/integration/conversation/ConversationTest.php index 9b9b539b..15a6daee 100644 --- a/tests/integration/conversation/ConversationTest.php +++ b/tests/integration/conversation/ConversationTest.php @@ -94,7 +94,7 @@ class ConversationTest extends BaseTest "lastUsedChannelId": "channel-id" }'; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/conversation/ConversationWebhookTest.php b/tests/integration/conversation/ConversationWebhookTest.php index 44472c52..acf236fe 100644 --- a/tests/integration/conversation/ConversationWebhookTest.php +++ b/tests/integration/conversation/ConversationWebhookTest.php @@ -37,7 +37,7 @@ class ConversationWebhookTest extends BaseTest "updatedDatetime": "2018-07-20T12:13:51+00:00" }'; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/integration/groups/GroupTest.php b/tests/integration/groups/GroupTest.php index f3664ffe..a9d5f0d7 100644 --- a/tests/integration/groups/GroupTest.php +++ b/tests/integration/groups/GroupTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/hlr/HlrTest.php b/tests/integration/hlr/HlrTest.php index dd2c94cf..11b6d2a2 100644 --- a/tests/integration/hlr/HlrTest.php +++ b/tests/integration/hlr/HlrTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/lookup/LookupTest.php b/tests/integration/lookup/LookupTest.php index bd85c543..8e6af2a6 100644 --- a/tests/integration/lookup/LookupTest.php +++ b/tests/integration/lookup/LookupTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/messages/MessagesTest.php b/tests/integration/messages/MessagesTest.php index b74648d9..b7a71d1c 100644 --- a/tests/integration/messages/MessagesTest.php +++ b/tests/integration/messages/MessagesTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/partneraccount/AccountTest.php b/tests/integration/partneraccount/AccountTest.php index 1b9a5f7f..68206f9d 100644 --- a/tests/integration/partneraccount/AccountTest.php +++ b/tests/integration/partneraccount/AccountTest.php @@ -2,7 +2,7 @@ class AccountTest extends BaseTest { - public function setUp() + protected function setUp(): void { parent::setUp(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/verify/VerifyTest.php b/tests/integration/verify/VerifyTest.php index 4939ce63..8ab47b32 100644 --- a/tests/integration/verify/VerifyTest.php +++ b/tests/integration/verify/VerifyTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/voice/VoiceTest.php b/tests/integration/voice/VoiceTest.php index 4bbbfb58..445f4a42 100644 --- a/tests/integration/voice/VoiceTest.php +++ b/tests/integration/voice/VoiceTest.php @@ -5,7 +5,7 @@ class VoiceTest extends BaseTest /** @var \MessageBird\Client client */ public $client; - public function setUp() + protected function setUp(): void { parent::setUp(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/voicemessages/VoiceMessagesTest.php b/tests/integration/voicemessages/VoiceMessagesTest.php index c9d858f7..e50205fc 100644 --- a/tests/integration/voicemessages/VoiceMessagesTest.php +++ b/tests/integration/voicemessages/VoiceMessagesTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/unit/RequestValidatorTest.php b/tests/unit/RequestValidatorTest.php index a057082b..f01addd8 100644 --- a/tests/unit/RequestValidatorTest.php +++ b/tests/unit/RequestValidatorTest.php @@ -2,8 +2,9 @@ use MessageBird\Objects\SignedRequest; use MessageBird\RequestValidator; +use PHPUnit\Framework\TestCase; -class RequestValidatorTest extends PHPUnit_Framework_TestCase +class RequestValidatorTest extends TestCase { public function testVerify() { diff --git a/tests/unit/SignedRequestTest.php b/tests/unit/SignedRequestTest.php index dc406d61..004c3cad 100644 --- a/tests/unit/SignedRequestTest.php +++ b/tests/unit/SignedRequestTest.php @@ -1,8 +1,9 @@ Date: Tue, 7 Jan 2020 17:58:37 +0100 Subject: [PATCH 2/6] Refactor deprecated PHPUnit annotations --- tests/integration/BaseTest.php | 3 - tests/integration/HttpClientTest.php | 11 ++-- tests/integration/balance/BalanceTest.php | 4 +- tests/integration/chat/ChatTest.php | 40 ++++--------- tests/integration/contacts/ContactTest.php | 12 +--- tests/integration/groups/GroupTest.php | 12 +--- tests/integration/hlr/HlrTest.php | 8 +-- tests/integration/lookup/LookupTest.php | 36 +++--------- tests/integration/messages/MessagesTest.php | 24 ++------ tests/integration/mms/MmsTest.php | 12 +--- tests/integration/verify/VerifyTest.php | 8 +-- tests/integration/voice/VoiceTest.php | 56 +++++-------------- .../voicemessages/VoiceMessagesTest.php | 16 ++---- tests/unit/SignedRequestTest.php | 24 +++----- 14 files changed, 69 insertions(+), 197 deletions(-) diff --git a/tests/integration/BaseTest.php b/tests/integration/BaseTest.php index 808cc1bc..4ea04a8b 100644 --- a/tests/integration/BaseTest.php +++ b/tests/integration/BaseTest.php @@ -40,9 +40,6 @@ public function testClientConstructor() $this->assertInstanceOf('MessageBird\Resources\Chat\Platform', $MessageBird->chatPlatforms); $this->assertInstanceOf('MessageBird\Resources\Chat\Channel', $MessageBird->chatChannels); $this->assertInstanceOf('MessageBird\Resources\Chat\Contact', $MessageBird->chatContacts); - $this->assertInstanceOf('MessageBird\Resources\AvailableNumbers', $MessageBird->availableNumbers); - $this->assertInstanceOf('MessageBird\Resources\PurchasedNumbers', $MessageBird->purchasedNumbers); - } public function testHttpClientMock() diff --git a/tests/integration/HttpClientTest.php b/tests/integration/HttpClientTest.php index 0db94230..2375ae5f 100644 --- a/tests/integration/HttpClientTest.php +++ b/tests/integration/HttpClientTest.php @@ -33,12 +33,10 @@ public function testHttpClientValidTimeoutBoundary() $this->doAssertionToNotBeConsideredRiskyTest(); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp #^Connection timeout must be an int >= 0, got "stdClass".$# - */ public function testHttpClientInvalidConnectionTimeout() { + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessageRegExp('#^Connection timeout must be an int >= 0, got "stdClass".$#'); new HttpClient(Client::ENDPOINT, 10, new \stdClass()); } @@ -54,12 +52,11 @@ public function testHttpClientValidConnectionTimeoutBoundary() /** * Test that requests can only be made when there is an Authentication set - * - * @expectedException \MessageBird\Exceptions\AuthenticateException - * @expectedExceptionMessageRegExp #Can not perform API Request without Authentication# */ public function testHttpClientWithoutAuthenticationException() { + $this->expectException('MessageBird\Exceptions\AuthenticateException'); + $this->expectExceptionMessageRegExp('#Can not perform API Request without Authentication#'); $client = new HttpClient(Client::ENDPOINT); $client->performHttpRequest('foo', 'bar'); } diff --git a/tests/integration/balance/BalanceTest.php b/tests/integration/balance/BalanceTest.php index 14fb813e..2d1e3dfe 100644 --- a/tests/integration/balance/BalanceTest.php +++ b/tests/integration/balance/BalanceTest.php @@ -7,11 +7,9 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadBalance() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'balance', null, null); $this->client->balance->read(); diff --git a/tests/integration/chat/ChatTest.php b/tests/integration/chat/ChatTest.php index 2cccb213..3f7c6c46 100644 --- a/tests/integration/chat/ChatTest.php +++ b/tests/integration/chat/ChatTest.php @@ -19,20 +19,16 @@ public function testCreateChatMessage() $this->client->chatMessages->create($ChatMessage); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListChatMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); $ChatMessageList = $this->client->chatMessages->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadChatMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages/id', null, null); $ChatMessageList = $this->client->chatMessages->read("id"); } @@ -55,29 +51,23 @@ public function testCreateChatChannel() $this->client->chatChannels->create($ChatChannel); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListChatChannels() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels', array ('offset' => 100, 'limit' => 30), null); $ChannelList = $this->client->chatChannels->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadChatChannel() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels/id', null, null); $Channel = $this->client->chatChannels->read("id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDeleteChannel() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'channels/id', null, null); $Channel = $this->client->chatChannels->delete("id"); } @@ -93,47 +83,37 @@ public function testUpdateChatChannel() $this->client->chatChannels->update($ChatChannel,'234agfgADFH2974gaADFH3hudf9h'); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListChatPlatforms() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms', array ('offset' => 100, 'limit' => 30), null); $ChannelList = $this->client->chatPlatforms->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadChatPlatform() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms/id', null, null); $Channel = $this->client->chatPlatforms->read("id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListChatContacts() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); $ContactList = $this->client->chatContacts->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadChatContact() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/id', null, null); $Contact = $this->client->chatContacts->read("id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDeleteContact() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/id', null, null); $contact = $this->client->chatContacts->delete("id"); } diff --git a/tests/integration/contacts/ContactTest.php b/tests/integration/contacts/ContactTest.php index 4eebb3df..b8f55c13 100644 --- a/tests/integration/contacts/ContactTest.php +++ b/tests/integration/contacts/ContactTest.php @@ -45,29 +45,23 @@ public function testCreateContact() $this->client->contacts->create($Contact); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListContacts() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); $this->client->contacts->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testViewContact() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/contact_id', null, null); $this->client->contacts->read("contact_id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDeleteContact() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/contact_id', null, null); $this->client->contacts->delete("contact_id"); } diff --git a/tests/integration/groups/GroupTest.php b/tests/integration/groups/GroupTest.php index a9d5f0d7..3fdd7a10 100644 --- a/tests/integration/groups/GroupTest.php +++ b/tests/integration/groups/GroupTest.php @@ -27,29 +27,23 @@ public function testCreateGroup() $this->client->groups->create($Group); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListGroups() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups', array ('offset' => 100, 'limit' => 30), null); $this->client->groups->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testViewGroup() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups/group_id', null, null); $this->client->groups->read("group_id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDeleteGroup() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'groups/group_id', null, null); $this->client->groups->delete("group_id"); } diff --git a/tests/integration/hlr/HlrTest.php b/tests/integration/hlr/HlrTest.php index 11b6d2a2..7b5c5f1a 100644 --- a/tests/integration/hlr/HlrTest.php +++ b/tests/integration/hlr/HlrTest.php @@ -7,11 +7,9 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testCreateHlr() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = 'MessageBird'; $Hlr->reference = "yoloswag3000"; @@ -21,11 +19,9 @@ public function testCreateHlr() } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadHlr() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'hlr/message_id', null, null); $this->client->hlr->read("message_id"); } diff --git a/tests/integration/lookup/LookupTest.php b/tests/integration/lookup/LookupTest.php index 8e6af2a6..a13fd076 100644 --- a/tests/integration/lookup/LookupTest.php +++ b/tests/integration/lookup/LookupTest.php @@ -7,38 +7,30 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadLookup() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/31612345678', null, null); $this->client->lookup->read(31612345678); } - /** - * @expectedException InvalidArgumentException - */ public function testReadLookupWithEmptyNumber() { + $this->expectException('InvalidArgumentException'); $this->client->lookup->read(null); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadLookupWithCountryCode() { + $this->expectException('MessageBird\Exceptions\ServerException'); $params = array("countryCode" => "NL"); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/612345678', $params, null); $this->client->lookup->read(612345678, $params["countryCode"]); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testCreateLookupHlr() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = 31612345678; $Hlr->reference = 'Yoloswag3007'; @@ -48,21 +40,17 @@ public function testCreateLookupHlr() $this->client->lookupHlr->create($Hlr); } - /** - * @expectedException InvalidArgumentException - */ public function testCreateLookupHlrWithEmptyNumber() { + $this->expectException('InvalidArgumentException'); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = null; $this->client->lookupHlr->create($Hlr); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testCreateLookupHlrWithCountryCode() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = 612345678; $Hlr->reference = "CoolReference"; @@ -74,28 +62,22 @@ public function testCreateLookupHlrWithCountryCode() $this->client->lookupHlr->create($Hlr, $params["countryCode"]); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadLookupHlr() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/31612345678/hlr', null, null); $this->client->lookupHlr->read(31612345678); } - /** - * @expectedException InvalidArgumentException - */ public function testReadLookupHlrWithEmptyNumber() { + $this->expectException('InvalidArgumentException'); $this->client->lookupHlr->read(null); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadLookupHlrWithCountryCode() { + $this->expectException('MessageBird\Exceptions\ServerException'); $params = array("countryCode" => "NL"); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/612345678/hlr', $params, null); $this->client->lookupHlr->read(612345678, $params["countryCode"]); diff --git a/tests/integration/messages/MessagesTest.php b/tests/integration/messages/MessagesTest.php index b7a71d1c..55c96e81 100644 --- a/tests/integration/messages/MessagesTest.php +++ b/tests/integration/messages/MessagesTest.php @@ -50,11 +50,9 @@ public function testCreateMessage() $this->client->messages->create($Message); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testPremiumSmsMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -64,11 +62,9 @@ public function testPremiumSmsMessage() $this->client->messages->create($Message); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testBinarySmsMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -79,11 +75,9 @@ public function testBinarySmsMessage() } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testFlashSmsMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -95,29 +89,23 @@ public function testFlashSmsMessage() } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); $this->client->messages->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages/message_id', null, null); $this->client->messages->read("message_id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDeleteMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'messages/message_id', null, null); $this->client->messages->delete("message_id"); } diff --git a/tests/integration/mms/MmsTest.php b/tests/integration/mms/MmsTest.php index f827e09e..026e60cc 100644 --- a/tests/integration/mms/MmsTest.php +++ b/tests/integration/mms/MmsTest.php @@ -1,11 +1,9 @@ expectException('MessageBird\Exceptions\RequestException'); $MmsMessage = new \MessageBird\Objects\MmsMessage(); $this->mockClient->expects($this->once()) @@ -64,11 +62,9 @@ public function testListMms() } - /** - * @expectedException \MessageBird\Exceptions\RequestException - */ public function testDeleteMms() { + $this->expectException('MessageBird\Exceptions\RequestException'); $this->mockClient->expects($this->exactly(2)) ->method('performHttpRequest') ->with('DELETE', 'mms/message_id', null, null) @@ -83,11 +79,9 @@ public function testDeleteMms() $this->client->mmsMessages->delete('message_id'); } - /** - * @expectedException \MessageBird\Exceptions\RequestException - */ public function testReadMms() { + $this->expectException('MessageBird\Exceptions\RequestException'); $dummyMessage = $this->generateDummyMessage(); $this->mockClient->expects($this->exactly(2)) diff --git a/tests/integration/verify/VerifyTest.php b/tests/integration/verify/VerifyTest.php index 8ab47b32..1cc703dc 100644 --- a/tests/integration/verify/VerifyTest.php +++ b/tests/integration/verify/VerifyTest.php @@ -7,11 +7,9 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testGenerateOtp() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Verify = new \MessageBird\Objects\Verify(); $Verify->recipient = 31612345678; $Verify->reference = "Yoloswag3000"; @@ -21,11 +19,9 @@ public function testGenerateOtp() $this->client->verify->create($Verify); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testVerifyOtp() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Verify = new \MessageBird\Objects\Verify(); $Verify->recipient = 31612345678; $Verify->reference = 'Yoloswag3000'; diff --git a/tests/integration/voice/VoiceTest.php b/tests/integration/voice/VoiceTest.php index 445f4a42..c8f71d84 100644 --- a/tests/integration/voice/VoiceTest.php +++ b/tests/integration/voice/VoiceTest.php @@ -11,11 +11,9 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListVoiceCall() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls', array( 'offset' => 100, 'limit' => 30, @@ -23,11 +21,9 @@ public function testListVoiceCall() $this->client->voiceCalls->getList(array('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadVoiceCall() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foobar', null, null); $this->client->voiceCalls->read('foobar'); } @@ -66,11 +62,9 @@ public function testCreateVoiceCall() $this->client->voiceCalls->create($voiceCall); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListVoiceLegs() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foobar/legs', array( 'offset' => 100, 'limit' => 30, @@ -78,20 +72,16 @@ public function testListVoiceLegs() $this->client->voiceLegs->getList('foobar', array('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadVoiceLeg() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar', null, null); $this->client->voiceLegs->read('foo', 'bar'); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListVoiceRecordings() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings', array( 'offset' => 100, 'limit' => 30, @@ -99,21 +89,17 @@ public function testListVoiceRecordings() $this->client->voiceRecordings->getList('foo', 'bar', array('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadVoiceRecording() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz', null, null); $this->client->voiceRecordings->read('foo', 'bar', 'baz'); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDownloadVoiceRecording() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz.wav', null, null); $this->client->voiceRecordings->download('foo', 'bar', 'baz'); } @@ -139,11 +125,9 @@ public function testCreateVoiceTranscription() $this->client->voiceTranscriptions->create('foo', 'bar', 'baz'); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListVoiceTranscriptions() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions', array( 'offset' => 100, 'limit' => 30, @@ -151,29 +135,23 @@ public function testListVoiceTranscriptions() $this->client->voiceTranscriptions->getList('foo', 'bar', 'baz', array('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadVoiceTranscription() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions/bups', null, null); $this->client->voiceTranscriptions->read('foo', 'bar', 'baz', 'bups'); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDownloadVoiceTranscription() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions/bups.txt', null, null); $this->client->voiceTranscriptions->download('foo', 'bar', 'baz', 'bups'); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListVoiceWebhooks() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'webhooks', array( 'offset' => 100, 'limit' => 30, @@ -181,11 +159,9 @@ public function testListVoiceWebhooks() $this->client->voiceWebhooks->getList(array('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadVoiceWebhook() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'webhooks/foobar', null, null); $this->client->voiceWebhooks->read('foobar'); } @@ -255,11 +231,9 @@ public function testDeleteVoiceWebhook() } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListVoiceCallFlows() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'call-flows', array( 'offset' => 100, 'limit' => 30, @@ -267,11 +241,9 @@ public function testListVoiceCallFlows() $this->client->voiceCallFlows->getList(array('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadVoiceCallFlow() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'call-flows/foobar', null, null); $this->client->voiceCallFlows->read('foobar'); } diff --git a/tests/integration/voicemessages/VoiceMessagesTest.php b/tests/integration/voicemessages/VoiceMessagesTest.php index e50205fc..7c1ee349 100644 --- a/tests/integration/voicemessages/VoiceMessagesTest.php +++ b/tests/integration/voicemessages/VoiceMessagesTest.php @@ -7,11 +7,9 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testVoiceMessageCreate() { + $this->expectException('MessageBird\Exceptions\ServerException'); $Message = new \MessageBird\Objects\VoiceMessage(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -22,29 +20,23 @@ public function testVoiceMessageCreate() $this->client->voicemessages->create($Message); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testListMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'voicemessages', array ('offset' => 100, 'limit' => 30), null); $this->client->voicemessages->getList(array ('offset' => 100, 'limit' => 30)); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testReadMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'voicemessages/message_id', null, null); $this->client->voicemessages->read("message_id"); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ public function testDeleteMessage() { + $this->expectException('MessageBird\Exceptions\ServerException'); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'voicemessages/message_id', null, null); $this->client->voicemessages->delete("message_id"); } diff --git a/tests/unit/SignedRequestTest.php b/tests/unit/SignedRequestTest.php index 004c3cad..6a972a0c 100644 --- a/tests/unit/SignedRequestTest.php +++ b/tests/unit/SignedRequestTest.php @@ -57,12 +57,10 @@ public function testLoadFromArray() self::assertEquals($signature, $request->signature); } - /** - * @expectedException \MessageBird\Exceptions\ValidationException - * @expectedExceptionMessage query - */ public function testLoadInvalidQuery() { + $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectExceptionMessage('query'); $query = null; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; $requestTimestamp = 1547198231; @@ -77,12 +75,10 @@ public function testLoadInvalidQuery() )); } - /** - * @expectedException \MessageBird\Exceptions\ValidationException - * @expectedExceptionMessage signature - */ public function testLoadInvalidSignature() { + $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectExceptionMessage('signature'); $query = array( 'recipient' => '31612345678', 'reference' => 'FOO', @@ -105,12 +101,10 @@ public function testLoadInvalidSignature() )); } - /** - * @expectedException \MessageBird\Exceptions\ValidationException - * @expectedExceptionMessage requestTimestamp - */ public function testLoadInvalidTimestamp() { + $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectExceptionMessage('requestTimestamp'); $query = array( 'recipient' => '31612345678', 'reference' => 'FOO', @@ -133,12 +127,10 @@ public function testLoadInvalidTimestamp() )); } - /** - * @expectedException \MessageBird\Exceptions\ValidationException - * @expectedExceptionMessage body - */ public function testLoadInvalidBody() { + $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectExceptionMessage('body'); $query = array( 'recipient' => '31612345678', 'reference' => 'FOO', From 13aa71ab25c6886516adc0259071cb5538f6ad10 Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Wed, 8 Jan 2020 10:52:52 +0100 Subject: [PATCH 3/6] Remove unsupported PHP versions from Travis matrix --- .travis.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d1135dc..de597358 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,10 @@ language: php -dist: trusty +dist: xenial php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - 7.3 - - hhvm - - hhvm-nightly - -matrix: - allow_failures: - - php: hhvm - - php: hhvm-nightly + - 7.4 before_script: - - if [[ "$TRAVIS_PHP_VERSION" == "hhvm"* ]]; then curl -sSfL -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi - composer install script: phpunit --verbose From 11e84946eb88a0cec00f571471003e70af7e315d Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Wed, 8 Jan 2020 12:56:51 +0100 Subject: [PATCH 4/6] Update supported php version --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index ab861043..40a17863 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,8 @@ } ], "require": { - "php": ">=5.4.0", - "ext-curl": "*", - "symfony/polyfill-php56": "^1.10" + "php": ">=7.2.0", + "ext-curl": "*" }, "require-dev": { "phpunit/phpunit": "^8" From 86bb65572282d54e63a1113391d23519514f5458 Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Wed, 8 Jan 2020 12:57:08 +0100 Subject: [PATCH 5/6] Remove deprecated phpunit config --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0500a7ee..632f92e1 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="autoload.php" > From 80daf14ae0e5d417074b47f9616a0776a0e0760d Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Wed, 8 Jan 2020 13:27:26 +0100 Subject: [PATCH 6/6] Use class references instead of strings on test assertions --- tests/integration/HttpClientTest.php | 8 +++--- tests/integration/balance/BalanceTest.php | 1 - tests/integration/chat/ChatTest.php | 20 ++++++------- tests/integration/contacts/ContactTest.php | 6 ++-- tests/integration/groups/GroupTest.php | 6 ++-- tests/integration/hlr/HlrTest.php | 4 +-- tests/integration/lookup/LookupTest.php | 18 ++++++------ tests/integration/messages/MessagesTest.php | 12 ++++---- tests/integration/mms/MmsTest.php | 6 ++-- tests/integration/verify/VerifyTest.php | 4 +-- tests/integration/voice/VoiceTest.php | 28 +++++++++---------- .../voicemessages/VoiceMessagesTest.php | 8 +++--- tests/unit/SignedRequestTest.php | 8 +++--- 13 files changed, 64 insertions(+), 65 deletions(-) diff --git a/tests/integration/HttpClientTest.php b/tests/integration/HttpClientTest.php index 2375ae5f..1d93de30 100644 --- a/tests/integration/HttpClientTest.php +++ b/tests/integration/HttpClientTest.php @@ -35,8 +35,8 @@ public function testHttpClientValidTimeoutBoundary() public function testHttpClientInvalidConnectionTimeout() { - $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessageRegExp('#^Connection timeout must be an int >= 0, got "stdClass".$#'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessageRegExp('/^Connection timeout must be an int >= 0, got "stdClass".$/'); new HttpClient(Client::ENDPOINT, 10, new \stdClass()); } @@ -55,8 +55,8 @@ public function testHttpClientValidConnectionTimeoutBoundary() */ public function testHttpClientWithoutAuthenticationException() { - $this->expectException('MessageBird\Exceptions\AuthenticateException'); - $this->expectExceptionMessageRegExp('#Can not perform API Request without Authentication#'); + $this->expectException(\MessageBird\Exceptions\AuthenticateException::class); + $this->expectExceptionMessageRegExp('/Can not perform API Request without Authentication/'); $client = new HttpClient(Client::ENDPOINT); $client->performHttpRequest('foo', 'bar'); } diff --git a/tests/integration/balance/BalanceTest.php b/tests/integration/balance/BalanceTest.php index 2d1e3dfe..bde69ed8 100644 --- a/tests/integration/balance/BalanceTest.php +++ b/tests/integration/balance/BalanceTest.php @@ -9,7 +9,6 @@ protected function setUp(): void public function testReadBalance() { - $this->expectException('MessageBird\Exceptions\ServerException'); $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'balance', null, null); $this->client->balance->read(); diff --git a/tests/integration/chat/ChatTest.php b/tests/integration/chat/ChatTest.php index 3f7c6c46..bc9c79e3 100644 --- a/tests/integration/chat/ChatTest.php +++ b/tests/integration/chat/ChatTest.php @@ -21,14 +21,14 @@ public function testCreateChatMessage() public function testListChatMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); $ChatMessageList = $this->client->chatMessages->getList(array ('offset' => 100, 'limit' => 30)); } public function testReadChatMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages/id', null, null); $ChatMessageList = $this->client->chatMessages->read("id"); } @@ -53,21 +53,21 @@ public function testCreateChatChannel() public function testListChatChannels() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels', array ('offset' => 100, 'limit' => 30), null); $ChannelList = $this->client->chatChannels->getList(array ('offset' => 100, 'limit' => 30)); } public function testReadChatChannel() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels/id', null, null); $Channel = $this->client->chatChannels->read("id"); } public function testDeleteChannel() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'channels/id', null, null); $Channel = $this->client->chatChannels->delete("id"); } @@ -85,35 +85,35 @@ public function testUpdateChatChannel() public function testListChatPlatforms() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms', array ('offset' => 100, 'limit' => 30), null); $ChannelList = $this->client->chatPlatforms->getList(array ('offset' => 100, 'limit' => 30)); } public function testReadChatPlatform() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms/id', null, null); $Channel = $this->client->chatPlatforms->read("id"); } public function testListChatContacts() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); $ContactList = $this->client->chatContacts->getList(array ('offset' => 100, 'limit' => 30)); } public function testReadChatContact() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/id', null, null); $Contact = $this->client->chatContacts->read("id"); } public function testDeleteContact() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/id', null, null); $contact = $this->client->chatContacts->delete("id"); } diff --git a/tests/integration/contacts/ContactTest.php b/tests/integration/contacts/ContactTest.php index b8f55c13..ae511e51 100644 --- a/tests/integration/contacts/ContactTest.php +++ b/tests/integration/contacts/ContactTest.php @@ -47,21 +47,21 @@ public function testCreateContact() public function testListContacts() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); $this->client->contacts->getList(array ('offset' => 100, 'limit' => 30)); } public function testViewContact() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/contact_id', null, null); $this->client->contacts->read("contact_id"); } public function testDeleteContact() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/contact_id', null, null); $this->client->contacts->delete("contact_id"); } diff --git a/tests/integration/groups/GroupTest.php b/tests/integration/groups/GroupTest.php index 3fdd7a10..4ab0e8d5 100644 --- a/tests/integration/groups/GroupTest.php +++ b/tests/integration/groups/GroupTest.php @@ -29,21 +29,21 @@ public function testCreateGroup() public function testListGroups() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups', array ('offset' => 100, 'limit' => 30), null); $this->client->groups->getList(array ('offset' => 100, 'limit' => 30)); } public function testViewGroup() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups/group_id', null, null); $this->client->groups->read("group_id"); } public function testDeleteGroup() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'groups/group_id', null, null); $this->client->groups->delete("group_id"); } diff --git a/tests/integration/hlr/HlrTest.php b/tests/integration/hlr/HlrTest.php index 7b5c5f1a..34f9d9bd 100644 --- a/tests/integration/hlr/HlrTest.php +++ b/tests/integration/hlr/HlrTest.php @@ -9,7 +9,7 @@ protected function setUp(): void public function testCreateHlr() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = 'MessageBird'; $Hlr->reference = "yoloswag3000"; @@ -21,7 +21,7 @@ public function testCreateHlr() public function testReadHlr() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'hlr/message_id', null, null); $this->client->hlr->read("message_id"); } diff --git a/tests/integration/lookup/LookupTest.php b/tests/integration/lookup/LookupTest.php index a13fd076..a8906d93 100644 --- a/tests/integration/lookup/LookupTest.php +++ b/tests/integration/lookup/LookupTest.php @@ -9,20 +9,20 @@ protected function setUp(): void public function testReadLookup() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/31612345678', null, null); $this->client->lookup->read(31612345678); } public function testReadLookupWithEmptyNumber() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->client->lookup->read(null); } public function testReadLookupWithCountryCode() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $params = array("countryCode" => "NL"); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/612345678', $params, null); $this->client->lookup->read(612345678, $params["countryCode"]); @@ -30,7 +30,7 @@ public function testReadLookupWithCountryCode() public function testCreateLookupHlr() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = 31612345678; $Hlr->reference = 'Yoloswag3007'; @@ -42,7 +42,7 @@ public function testCreateLookupHlr() public function testCreateLookupHlrWithEmptyNumber() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = null; $this->client->lookupHlr->create($Hlr); @@ -50,7 +50,7 @@ public function testCreateLookupHlrWithEmptyNumber() public function testCreateLookupHlrWithCountryCode() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Hlr = new \MessageBird\Objects\Hlr(); $Hlr->msisdn = 612345678; $Hlr->reference = "CoolReference"; @@ -64,20 +64,20 @@ public function testCreateLookupHlrWithCountryCode() public function testReadLookupHlr() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/31612345678/hlr', null, null); $this->client->lookupHlr->read(31612345678); } public function testReadLookupHlrWithEmptyNumber() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->client->lookupHlr->read(null); } public function testReadLookupHlrWithCountryCode() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $params = array("countryCode" => "NL"); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/612345678/hlr', $params, null); $this->client->lookupHlr->read(612345678, $params["countryCode"]); diff --git a/tests/integration/messages/MessagesTest.php b/tests/integration/messages/MessagesTest.php index 55c96e81..c558b521 100644 --- a/tests/integration/messages/MessagesTest.php +++ b/tests/integration/messages/MessagesTest.php @@ -52,7 +52,7 @@ public function testCreateMessage() public function testPremiumSmsMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -64,7 +64,7 @@ public function testPremiumSmsMessage() public function testBinarySmsMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -77,7 +77,7 @@ public function testBinarySmsMessage() public function testFlashSmsMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -91,21 +91,21 @@ public function testFlashSmsMessage() public function testListMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); $this->client->messages->getList(array ('offset' => 100, 'limit' => 30)); } public function testReadMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages/message_id', null, null); $this->client->messages->read("message_id"); } public function testDeleteMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'messages/message_id', null, null); $this->client->messages->delete("message_id"); } diff --git a/tests/integration/mms/MmsTest.php b/tests/integration/mms/MmsTest.php index 026e60cc..3482457a 100644 --- a/tests/integration/mms/MmsTest.php +++ b/tests/integration/mms/MmsTest.php @@ -3,7 +3,7 @@ class MmsTest extends BaseTest { public function testCreateMmsFail() { - $this->expectException('MessageBird\Exceptions\RequestException'); + $this->expectException(\MessageBird\Exceptions\RequestException::class); $MmsMessage = new \MessageBird\Objects\MmsMessage(); $this->mockClient->expects($this->once()) @@ -64,7 +64,7 @@ public function testListMms() public function testDeleteMms() { - $this->expectException('MessageBird\Exceptions\RequestException'); + $this->expectException(\MessageBird\Exceptions\RequestException::class); $this->mockClient->expects($this->exactly(2)) ->method('performHttpRequest') ->with('DELETE', 'mms/message_id', null, null) @@ -81,7 +81,7 @@ public function testDeleteMms() public function testReadMms() { - $this->expectException('MessageBird\Exceptions\RequestException'); + $this->expectException(\MessageBird\Exceptions\RequestException::class); $dummyMessage = $this->generateDummyMessage(); $this->mockClient->expects($this->exactly(2)) diff --git a/tests/integration/verify/VerifyTest.php b/tests/integration/verify/VerifyTest.php index 1cc703dc..589e864d 100644 --- a/tests/integration/verify/VerifyTest.php +++ b/tests/integration/verify/VerifyTest.php @@ -9,7 +9,7 @@ protected function setUp(): void public function testGenerateOtp() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Verify = new \MessageBird\Objects\Verify(); $Verify->recipient = 31612345678; $Verify->reference = "Yoloswag3000"; @@ -21,7 +21,7 @@ public function testGenerateOtp() public function testVerifyOtp() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Verify = new \MessageBird\Objects\Verify(); $Verify->recipient = 31612345678; $Verify->reference = 'Yoloswag3000'; diff --git a/tests/integration/voice/VoiceTest.php b/tests/integration/voice/VoiceTest.php index c8f71d84..0d7cd7c2 100644 --- a/tests/integration/voice/VoiceTest.php +++ b/tests/integration/voice/VoiceTest.php @@ -13,7 +13,7 @@ protected function setUp(): void public function testListVoiceCall() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls', array( 'offset' => 100, 'limit' => 30, @@ -23,7 +23,7 @@ public function testListVoiceCall() public function testReadVoiceCall() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foobar', null, null); $this->client->voiceCalls->read('foobar'); } @@ -64,7 +64,7 @@ public function testCreateVoiceCall() public function testListVoiceLegs() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foobar/legs', array( 'offset' => 100, 'limit' => 30, @@ -74,14 +74,14 @@ public function testListVoiceLegs() public function testReadVoiceLeg() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar', null, null); $this->client->voiceLegs->read('foo', 'bar'); } public function testListVoiceRecordings() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings', array( 'offset' => 100, 'limit' => 30, @@ -91,7 +91,7 @@ public function testListVoiceRecordings() public function testReadVoiceRecording() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz', null, null); $this->client->voiceRecordings->read('foo', 'bar', 'baz'); } @@ -99,7 +99,7 @@ public function testReadVoiceRecording() public function testDownloadVoiceRecording() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz.wav', null, null); $this->client->voiceRecordings->download('foo', 'bar', 'baz'); } @@ -127,7 +127,7 @@ public function testCreateVoiceTranscription() public function testListVoiceTranscriptions() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions', array( 'offset' => 100, 'limit' => 30, @@ -137,21 +137,21 @@ public function testListVoiceTranscriptions() public function testReadVoiceTranscription() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions/bups', null, null); $this->client->voiceTranscriptions->read('foo', 'bar', 'baz', 'bups'); } public function testDownloadVoiceTranscription() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions/bups.txt', null, null); $this->client->voiceTranscriptions->download('foo', 'bar', 'baz', 'bups'); } public function testListVoiceWebhooks() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'webhooks', array( 'offset' => 100, 'limit' => 30, @@ -161,7 +161,7 @@ public function testListVoiceWebhooks() public function testReadVoiceWebhook() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'webhooks/foobar', null, null); $this->client->voiceWebhooks->read('foobar'); } @@ -233,7 +233,7 @@ public function testDeleteVoiceWebhook() public function testListVoiceCallFlows() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'call-flows', array( 'offset' => 100, 'limit' => 30, @@ -243,7 +243,7 @@ public function testListVoiceCallFlows() public function testReadVoiceCallFlow() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'call-flows/foobar', null, null); $this->client->voiceCallFlows->read('foobar'); } diff --git a/tests/integration/voicemessages/VoiceMessagesTest.php b/tests/integration/voicemessages/VoiceMessagesTest.php index 7c1ee349..6ea883a2 100644 --- a/tests/integration/voicemessages/VoiceMessagesTest.php +++ b/tests/integration/voicemessages/VoiceMessagesTest.php @@ -9,7 +9,7 @@ protected function setUp(): void public function testVoiceMessageCreate() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\VoiceMessage(); $Message->originator = 'MessageBird'; $Message->recipients = array(31612345678); @@ -22,21 +22,21 @@ public function testVoiceMessageCreate() public function testListMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'voicemessages', array ('offset' => 100, 'limit' => 30), null); $this->client->voicemessages->getList(array ('offset' => 100, 'limit' => 30)); } public function testReadMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'voicemessages/message_id', null, null); $this->client->voicemessages->read("message_id"); } public function testDeleteMessage() { - $this->expectException('MessageBird\Exceptions\ServerException'); + $this->expectException(\MessageBird\Exceptions\ServerException::class); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'voicemessages/message_id', null, null); $this->client->voicemessages->delete("message_id"); } diff --git a/tests/unit/SignedRequestTest.php b/tests/unit/SignedRequestTest.php index 6a972a0c..56f25de8 100644 --- a/tests/unit/SignedRequestTest.php +++ b/tests/unit/SignedRequestTest.php @@ -59,7 +59,7 @@ public function testLoadFromArray() public function testLoadInvalidQuery() { - $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('query'); $query = null; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; @@ -77,7 +77,7 @@ public function testLoadInvalidQuery() public function testLoadInvalidSignature() { - $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('signature'); $query = array( 'recipient' => '31612345678', @@ -103,7 +103,7 @@ public function testLoadInvalidSignature() public function testLoadInvalidTimestamp() { - $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('requestTimestamp'); $query = array( 'recipient' => '31612345678', @@ -129,7 +129,7 @@ public function testLoadInvalidTimestamp() public function testLoadInvalidBody() { - $this->expectException('MessageBird\Exceptions\ValidationException'); + $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('body'); $query = array( 'recipient' => '31612345678',