Skip to content

Update PHPUnit to 8.x and drop unsupported versions #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
composer.phar
.DS_Store
.idea/
.phpunit.*
17 changes: 2 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
}
],
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"symfony/polyfill-php56": "^1.10"
"php": ">=7.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

BTW from #79 (comment) this could be published as a minor version bump and let composer's php version resolution to avoid having users of unsupported versions upgrade.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated in the README, it still says php >= 5.4

"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8.25"
"phpunit/phpunit": "^8"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="autoload.php"
>
<testsuites>
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/BaseTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<?php
// Starting from PHPUnit 6, PHPUnit classes are namespaced. This alias ensures our tests still run
// with PHPUnit >=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;

/** @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);
Expand Down Expand Up @@ -43,7 +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);

}

public function testHttpClientMock()
Expand Down
17 changes: 6 additions & 11 deletions tests/integration/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -35,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::class);
$this->expectExceptionMessageRegExp('/^Connection timeout must be an int >= 0, got "stdClass".$/');
new HttpClient(Client::ENDPOINT, 10, new \stdClass());
}

Expand All @@ -56,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::class);
$this->expectExceptionMessageRegExp('/Can not perform API Request without Authentication/');
$client = new HttpClient(Client::ENDPOINT);
$client->performHttpRequest('foo', 'bar');
}
Expand Down
6 changes: 2 additions & 4 deletions tests/integration/balance/BalanceTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?php
class BalanceTest extends BaseTest
{
public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
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();
}
Expand Down
42 changes: 11 additions & 31 deletions tests/integration/chat/ChatTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class ChatTest extends BaseTest
{
public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
Expand All @@ -19,20 +19,16 @@ public function testCreateChatMessage()
$this->client->chatMessages->create($ChatMessage);
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testListChatMessage()
{
$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));
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testReadChatMessage()
{
$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");
}
Expand All @@ -55,29 +51,23 @@ public function testCreateChatChannel()
$this->client->chatChannels->create($ChatChannel);
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testListChatChannels()
{
$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));
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testReadChatChannel()
{
$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");
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testDeleteChannel()
{
$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");
}
Expand All @@ -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::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));
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testReadChatPlatform()
{
$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");
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testListChatContacts()
{
$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));
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testReadChatContact()
{
$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");
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testDeleteContact()
{
$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");
}
Expand Down
14 changes: 4 additions & 10 deletions tests/integration/contacts/ContactTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class ContactTest extends BaseTest
{
public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
Expand Down Expand Up @@ -45,29 +45,23 @@ public function testCreateContact()
$this->client->contacts->create($Contact);
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testListContacts()
{
$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));
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testViewContact()
{
$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");
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testDeleteContact()
{
$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");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conversation/ConversationMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ConversationMessageTest extends BaseTest
"type": "video"
}';

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conversation/ConversationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ConversationTest extends BaseTest
"lastUsedChannelId": "channel-id"
}';

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conversation/ConversationWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
14 changes: 4 additions & 10 deletions tests/integration/groups/GroupTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class GroupTest extends BaseTest
{
public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
Expand All @@ -27,29 +27,23 @@ public function testCreateGroup()
$this->client->groups->create($Group);
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testListGroups()
{
$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));
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testViewGroup()
{
$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");
}

/**
* @expectedException MessageBird\Exceptions\ServerException
*/
public function testDeleteGroup()
{
$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");
}
Expand Down
Loading