Skip to content

Commit 11950ca

Browse files
author
marcel corso gonzalez
authored
Merge pull request #108 from paolobueno/phpunit-8
Update PHPUnit to 8.x and drop unsupported versions
2 parents 3e2fefa + 80daf14 commit 11950ca

23 files changed

+99
-242
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
composer.phar
44
.DS_Store
55
.idea/
6+
.phpunit.*

.travis.yml

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
language: php
2-
dist: trusty
2+
dist: xenial
33
php:
4-
- 5.4
5-
- 5.5
6-
- 5.6
7-
- 7.0
8-
- 7.1
9-
- 7.2
104
- 7.3
11-
- hhvm
12-
- hhvm-nightly
13-
14-
matrix:
15-
allow_failures:
16-
- php: hhvm
17-
- php: hhvm-nightly
5+
- 7.4
186

197
before_script:
20-
- if [[ "$TRAVIS_PHP_VERSION" == "hhvm"* ]]; then curl -sSfL -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi
218
- composer install
229

2310
script: phpunit --verbose

composer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.4.0",
15-
"ext-curl": "*",
16-
"symfony/polyfill-php56": "^1.10"
14+
"php": ">=7.2.0",
15+
"ext-curl": "*"
1716
},
1817
"require-dev": {
19-
"phpunit/phpunit": "^4.8.25"
18+
"phpunit/phpunit": "^8"
2019
},
2120
"autoload": {
2221
"psr-4": {

phpunit.xml.dist

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="autoload.php"
1312
>
1413
<testsuites>

tests/integration/BaseTest.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
<?php
2-
// Starting from PHPUnit 6, PHPUnit classes are namespaced. This alias ensures our tests still run
3-
// with PHPUnit >=6. See: https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-6.0.0
4-
if (!class_exists('PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
5-
class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
6-
}
72

8-
class BaseTest extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
class BaseTest extends TestCase
96
{
107
/** @var \MessageBird\Client */
118
protected $client;
129

1310
/** @var PHPUnit_Framework_MockObject_MockObject */
1411
protected $mockClient;
1512

16-
public function setUp()
13+
protected function setUp(): void
1714
{
1815
$this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(array("fake.messagebird.dev"))->getMock();
1916
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
@@ -43,7 +40,6 @@ public function testClientConstructor()
4340
$this->assertInstanceOf('MessageBird\Resources\Chat\Platform', $MessageBird->chatPlatforms);
4441
$this->assertInstanceOf('MessageBird\Resources\Chat\Channel', $MessageBird->chatChannels);
4542
$this->assertInstanceOf('MessageBird\Resources\Chat\Contact', $MessageBird->chatContacts);
46-
4743
}
4844

4945
public function testHttpClientMock()

tests/integration/HttpClientTest.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ public function testHttpClient()
1616
$this->assertSame(Client::ENDPOINT.'/a?b=1', $url);
1717
}
1818

19-
/**
20-
* @expectedException \InvalidArgumentException
21-
* @expectedExceptionMessageRegExp #^Timeout must be an int > 0, got "integer 0".$#
22-
*/
2319
public function testHttpClientInvalidTimeout()
2420
{
21+
$this->expectException(InvalidArgumentException::class);
22+
$this->expectExceptionMessageRegExp('/^Timeout must be an int > 0, got "integer 0".$/');
2523
new HttpClient(Client::ENDPOINT, 0);
2624
}
2725

@@ -35,12 +33,10 @@ public function testHttpClientValidTimeoutBoundary()
3533
$this->doAssertionToNotBeConsideredRiskyTest();
3634
}
3735

38-
/**
39-
* @expectedException \InvalidArgumentException
40-
* @expectedExceptionMessageRegExp #^Connection timeout must be an int >= 0, got "stdClass".$#
41-
*/
4236
public function testHttpClientInvalidConnectionTimeout()
4337
{
38+
$this->expectException(\InvalidArgumentException::class);
39+
$this->expectExceptionMessageRegExp('/^Connection timeout must be an int >= 0, got "stdClass".$/');
4440
new HttpClient(Client::ENDPOINT, 10, new \stdClass());
4541
}
4642

@@ -56,12 +52,11 @@ public function testHttpClientValidConnectionTimeoutBoundary()
5652

5753
/**
5854
* Test that requests can only be made when there is an Authentication set
59-
*
60-
* @expectedException \MessageBird\Exceptions\AuthenticateException
61-
* @expectedExceptionMessageRegExp #Can not perform API Request without Authentication#
6255
*/
6356
public function testHttpClientWithoutAuthenticationException()
6457
{
58+
$this->expectException(\MessageBird\Exceptions\AuthenticateException::class);
59+
$this->expectExceptionMessageRegExp('/Can not perform API Request without Authentication/');
6560
$client = new HttpClient(Client::ENDPOINT);
6661
$client->performHttpRequest('foo', 'bar');
6762
}

tests/integration/balance/BalanceTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?php
22
class BalanceTest extends BaseTest
33
{
4-
public function setUp()
4+
protected function setUp(): void
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
88
}
99

10-
/**
11-
* @expectedException MessageBird\Exceptions\ServerException
12-
*/
1310
public function testReadBalance()
1411
{
12+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
1513
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'balance', null, null);
1614
$this->client->balance->read();
1715
}

tests/integration/chat/ChatTest.php

+11-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class ChatTest extends BaseTest
33
{
4-
public function setUp()
4+
protected function setUp(): void
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
@@ -19,20 +19,16 @@ public function testCreateChatMessage()
1919
$this->client->chatMessages->create($ChatMessage);
2020
}
2121

22-
/**
23-
* @expectedException MessageBird\Exceptions\ServerException
24-
*/
2522
public function testListChatMessage()
2623
{
24+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
2725
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null);
2826
$ChatMessageList = $this->client->chatMessages->getList(array ('offset' => 100, 'limit' => 30));
2927
}
3028

31-
/**
32-
* @expectedException MessageBird\Exceptions\ServerException
33-
*/
3429
public function testReadChatMessage()
3530
{
31+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
3632
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages/id', null, null);
3733
$ChatMessageList = $this->client->chatMessages->read("id");
3834
}
@@ -55,29 +51,23 @@ public function testCreateChatChannel()
5551
$this->client->chatChannels->create($ChatChannel);
5652
}
5753

58-
/**
59-
* @expectedException MessageBird\Exceptions\ServerException
60-
*/
6154
public function testListChatChannels()
6255
{
56+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
6357
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels', array ('offset' => 100, 'limit' => 30), null);
6458
$ChannelList = $this->client->chatChannels->getList(array ('offset' => 100, 'limit' => 30));
6559
}
6660

67-
/**
68-
* @expectedException MessageBird\Exceptions\ServerException
69-
*/
7061
public function testReadChatChannel()
7162
{
63+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
7264
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels/id', null, null);
7365
$Channel = $this->client->chatChannels->read("id");
7466
}
7567

76-
/**
77-
* @expectedException MessageBird\Exceptions\ServerException
78-
*/
7968
public function testDeleteChannel()
8069
{
70+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
8171
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'channels/id', null, null);
8272
$Channel = $this->client->chatChannels->delete("id");
8373
}
@@ -93,47 +83,37 @@ public function testUpdateChatChannel()
9383
$this->client->chatChannels->update($ChatChannel,'234agfgADFH2974gaADFH3hudf9h');
9484
}
9585

96-
/**
97-
* @expectedException MessageBird\Exceptions\ServerException
98-
*/
9986
public function testListChatPlatforms()
10087
{
88+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
10189
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms', array ('offset' => 100, 'limit' => 30), null);
10290
$ChannelList = $this->client->chatPlatforms->getList(array ('offset' => 100, 'limit' => 30));
10391
}
10492

105-
/**
106-
* @expectedException MessageBird\Exceptions\ServerException
107-
*/
10893
public function testReadChatPlatform()
10994
{
95+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
11096
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms/id', null, null);
11197
$Channel = $this->client->chatPlatforms->read("id");
11298
}
11399

114-
/**
115-
* @expectedException MessageBird\Exceptions\ServerException
116-
*/
117100
public function testListChatContacts()
118101
{
102+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
119103
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null);
120104
$ContactList = $this->client->chatContacts->getList(array ('offset' => 100, 'limit' => 30));
121105
}
122106

123-
/**
124-
* @expectedException MessageBird\Exceptions\ServerException
125-
*/
126107
public function testReadChatContact()
127108
{
109+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
128110
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/id', null, null);
129111
$Contact = $this->client->chatContacts->read("id");
130112
}
131113

132-
/**
133-
* @expectedException MessageBird\Exceptions\ServerException
134-
*/
135114
public function testDeleteContact()
136115
{
116+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
137117
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/id', null, null);
138118
$contact = $this->client->chatContacts->delete("id");
139119
}

tests/integration/contacts/ContactTest.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class ContactTest extends BaseTest
33
{
4-
public function setUp()
4+
protected function setUp(): void
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
@@ -45,29 +45,23 @@ public function testCreateContact()
4545
$this->client->contacts->create($Contact);
4646
}
4747

48-
/**
49-
* @expectedException MessageBird\Exceptions\ServerException
50-
*/
5148
public function testListContacts()
5249
{
50+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
5351
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null);
5452
$this->client->contacts->getList(array ('offset' => 100, 'limit' => 30));
5553
}
5654

57-
/**
58-
* @expectedException MessageBird\Exceptions\ServerException
59-
*/
6055
public function testViewContact()
6156
{
57+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
6258
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/contact_id', null, null);
6359
$this->client->contacts->read("contact_id");
6460
}
6561

66-
/**
67-
* @expectedException MessageBird\Exceptions\ServerException
68-
*/
6962
public function testDeleteContact()
7063
{
64+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
7165
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/contact_id', null, null);
7266
$this->client->contacts->delete("contact_id");
7367
}

tests/integration/conversation/ConversationMessageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ConversationMessageTest extends BaseTest
4646
"type": "video"
4747
}';
4848

49-
public function setUp()
49+
protected function setUp(): void
5050
{
5151
parent::setUp();
5252

tests/integration/conversation/ConversationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class ConversationTest extends BaseTest
9494
"lastUsedChannelId": "channel-id"
9595
}';
9696

97-
public function setUp()
97+
protected function setUp(): void
9898
{
9999
parent::setUp();
100100

tests/integration/conversation/ConversationWebhookTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConversationWebhookTest extends BaseTest
3737
"updatedDatetime": "2018-07-20T12:13:51+00:00"
3838
}';
3939

40-
public function setUp()
40+
protected function setUp(): void
4141
{
4242
parent::setUp();
4343

tests/integration/groups/GroupTest.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class GroupTest extends BaseTest
33
{
4-
public function setUp()
4+
protected function setUp(): void
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
@@ -27,29 +27,23 @@ public function testCreateGroup()
2727
$this->client->groups->create($Group);
2828
}
2929

30-
/**
31-
* @expectedException MessageBird\Exceptions\ServerException
32-
*/
3330
public function testListGroups()
3431
{
32+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
3533
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups', array ('offset' => 100, 'limit' => 30), null);
3634
$this->client->groups->getList(array ('offset' => 100, 'limit' => 30));
3735
}
3836

39-
/**
40-
* @expectedException MessageBird\Exceptions\ServerException
41-
*/
4237
public function testViewGroup()
4338
{
39+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
4440
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups/group_id', null, null);
4541
$this->client->groups->read("group_id");
4642
}
4743

48-
/**
49-
* @expectedException MessageBird\Exceptions\ServerException
50-
*/
5144
public function testDeleteGroup()
5245
{
46+
$this->expectException(\MessageBird\Exceptions\ServerException::class);
5347
$this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'groups/group_id', null, null);
5448
$this->client->groups->delete("group_id");
5549
}

0 commit comments

Comments
 (0)