From ad0a5ed376a1ed7c5a6b83ad2df2c7c126dc2536 Mon Sep 17 00:00:00 2001 From: "Nek (Maxime Veber)" Date: Sat, 13 Nov 2021 18:44:23 +0100 Subject: [PATCH] feat: support php 8 in test suite --- .travis.yml | 5 +++-- composer.json | 4 ++-- phpunit.xml | 1 - src/Vinelab/Minion/Client.php | 3 +-- src/Vinelab/Minion/Minion.php | 7 +++--- tests/UnitTestCase.php | 2 +- tests/unit/ClientTest.php | 42 +++++++++++++++++------------------ tests/unit/DictionaryTest.php | 8 +++---- tests/unit/MinionTest.php | 22 +++++++++--------- tests/unit/ProviderTest.php | 6 ++--- 10 files changed, 49 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index cdfef54..a174ff2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: php php: - - 7.0 - - 7.1 + - 7.3 + - 7.4 + - 8.0 before_script: - travis_retry composer self-update diff --git a/composer.json b/composer.json index bda0683..b15a10e 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "illuminate/support": "^5.5|^6.0|^7.0", "illuminate/console": "^5.5|^6.0|^7.0", "thruway/client": "^0.5", @@ -20,7 +20,7 @@ "phpunit/phpunit": "^7|^8|^9", "mockery/mockery": "0.9.*|^1.0", "squizlabs/php_codesniffer": "^3.2", - "friendsofphp/php-cs-fixer": "^2.11" + "friendsofphp/php-cs-fixer": "^3.0" }, "autoload": { "psr-0": { diff --git a/phpunit.xml b/phpunit.xml index f69c9fa..e35e242 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" > diff --git a/src/Vinelab/Minion/Client.php b/src/Vinelab/Minion/Client.php index f2eb77f..943c626 100644 --- a/src/Vinelab/Minion/Client.php +++ b/src/Vinelab/Minion/Client.php @@ -63,7 +63,7 @@ public function onSessionStart($session, $transport) // also no longer a method on the Client class. // Shush the logs. // $this->getManager()->setQuiet(true); - + // Boot up providers $this->bootProviders(); } @@ -252,7 +252,6 @@ public function wrapWithProxy($callback, $isFunction = false) // We will wrap the callback with a Closure so that we can format the kwArgs that we receive // into our proprietary Dictionary instance to make things safer. return function ($args, $kwArgs, $details) use ($callback, $isFunction, $provider) { - if (is_string($callback) && !$isFunction && $provider instanceof Provider) { $callback = [$provider, $callback]; } diff --git a/src/Vinelab/Minion/Minion.php b/src/Vinelab/Minion/Minion.php index 28646f5..75639ee 100644 --- a/src/Vinelab/Minion/Minion.php +++ b/src/Vinelab/Minion/Minion.php @@ -84,7 +84,7 @@ public function run($options = [], LoopInterface $loop = null) /** * Get a new Client instance. - * + * * @param \React\EventLoop\LoopInterface $loop * * @return \Vinelab\Minion\Client @@ -113,10 +113,9 @@ public function transportUrl() { $proto = $this->getConfig('tls') ? 'wss' : 'ws'; $port = intval($this->getConfig('port')); - if($port>0) { + if ($port>0) { $port = ':'.$port; - } - else { + } else { $port = ''; } return $proto.'://'.$this->getConfig('host').$port.$this->getConfig('path'); diff --git a/tests/UnitTestCase.php b/tests/UnitTestCase.php index 7366001..1589474 100644 --- a/tests/UnitTestCase.php +++ b/tests/UnitTestCase.php @@ -5,7 +5,7 @@ */ class UnitTestCase extends PHPUnit\Framework\TestCase { - public function test_running() + public function test_running(): void { $this->asserttrue(true); } diff --git a/tests/unit/ClientTest.php b/tests/unit/ClientTest.php index 29d2bbf..907bdb2 100644 --- a/tests/unit/ClientTest.php +++ b/tests/unit/ClientTest.php @@ -8,26 +8,26 @@ */ class ClientTest extends UnitTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); $this->client = M::mock(new Client('i.the.divine', [])); } - public function tearDown() + public function tearDown(): void { M::close(); } - public function test_initializing_sets_providers() + public function test_initializing_sets_providers(): void { $providers = ['prov1', 'prov2']; $c = new Client('julia.dream', $providers); $this->assertEquals($providers, $c->getProviders()); } - public function test_on_session_start_boots_providers() + public function test_on_session_start_boots_providers(): void { $called = []; @@ -49,7 +49,7 @@ public function test_on_session_start_boots_providers() $this->assertInstanceOf('Vinelab\Minion\Client', $called['andMe']); } - public function test_preparing_topic() + public function test_preparing_topic(): void { $this->client->setTopicPrefix('some.topic.prefix.'); @@ -59,7 +59,7 @@ public function test_preparing_topic() $this->assertEquals('some.topic.prefix.', $this->client->getTopicPrefix()); } - public function test_subscribing_with_provider_method() + public function test_subscribing_with_provider_method(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -79,7 +79,7 @@ public function test_subscribing_with_provider_method() $this->assertEquals($promise, $got); } - public function test_subscribing_with_options() + public function test_subscribing_with_options(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -96,7 +96,7 @@ public function test_subscribing_with_options() $this->assertEquals($promise, $got); } - public function test_registering_with_options() + public function test_registering_with_options(): void { $session = M::mock('Thruway\ClientSession'); @@ -115,7 +115,7 @@ public function test_registering_with_options() $this->assertEquals($promise, $got); } - public function test_registering_with_function() + public function test_registering_with_function(): void { $session = M::mock('Thruway\ClientSession'); @@ -135,7 +135,7 @@ public function test_registering_with_function() $this->assertEquals($promise, $got); } - public function test_registering_prepares_topic() + public function test_registering_prepares_topic(): void { $session = M::mock('Thruway\ClientSession'); @@ -155,7 +155,7 @@ public function test_registering_prepares_topic() $this->assertEquals($promise, $got); } - public function test_calling_simple() + public function test_calling_simple(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -171,7 +171,7 @@ public function test_calling_simple() $this->assertEquals($promise, $got); } - public function test_calling_full() + public function test_calling_full(): void { $topic = 'pub.topic'; $arguments = ['dddddata' => 'hhhhhere']; @@ -190,7 +190,7 @@ public function test_calling_full() $this->assertEquals($promise, $got); } - public function test_calling_prepares_topic() + public function test_calling_prepares_topic(): void { $topic = 'pub.topic'; $prefixed = 'test.test.pub.test.pub.topic'; @@ -211,7 +211,7 @@ public function test_calling_prepares_topic() $this->assertEquals($promise, $got); } - public function test_registering_with_provider_method() + public function test_registering_with_provider_method(): void { $session = M::mock('Thruway\ClientSession'); @@ -231,7 +231,7 @@ public function test_registering_with_provider_method() $this->assertEquals($promise, $got); } - public function test_registering_with_closure() + public function test_registering_with_closure(): void { $session = M::mock('Thruway\ClientSession'); @@ -253,7 +253,7 @@ public function test_registering_with_closure() $this->assertEquals($promise, $got); } - public function test_publishing_prepares_topic() + public function test_publishing_prepares_topic(): void { $topic = 'pub.topic'; $prefixed = 'test.test.pub.test.pub.topic'; @@ -274,7 +274,7 @@ public function test_publishing_prepares_topic() $this->assertEquals($promise, $got); } - public function test_publishing_simple() + public function test_publishing_simple(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -290,7 +290,7 @@ public function test_publishing_simple() $this->assertEquals($promise, $got); } - public function test_subscribing_prepares_topic() + public function test_subscribing_prepares_topic(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -307,7 +307,7 @@ public function test_subscribing_prepares_topic() $this->assertEquals($promise, $got); } - public function test_subscribing_with_function() + public function test_subscribing_with_function(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -321,7 +321,7 @@ public function test_subscribing_with_function() $this->assertEquals($promise, $got); } - public function test_subscribing_with_closure() + public function test_subscribing_with_closure(): void { $session = M::mock('Thruway\ClientSession'); $promise = M::mock('React\Promise\Promise'); @@ -336,7 +336,7 @@ public function test_subscribing_with_closure() $this->assertEquals($promise, $got); } - public function test_publishing_full() + public function test_publishing_full(): void { $topic = 'pub.topic'; $arguments = ['dddddata' => 'hhhhhere']; diff --git a/tests/unit/DictionaryTest.php b/tests/unit/DictionaryTest.php index 90869d4..51ed13b 100644 --- a/tests/unit/DictionaryTest.php +++ b/tests/unit/DictionaryTest.php @@ -7,7 +7,7 @@ */ class DictionaryTest extends PHPUnit\Framework\TestCase { - public function test_initializing_dictionary() + public function test_initializing_dictionary(): void { $dict = Dictionary::make(['nick' => 'cave', 'back' => 'seeds']); @@ -15,7 +15,7 @@ public function test_initializing_dictionary() $this->assertEquals('seeds', $dict->back); } - public function test_initializing_with_object() + public function test_initializing_with_object(): void { $data = new StdClass(); $data->into = 'my arms'; @@ -27,7 +27,7 @@ public function test_initializing_with_object() $this->assertEquals('angels', $data->believe); } - public function test_array_representation() + public function test_array_representation(): void { $flying = new StdClass(); $flying->wings = 2; @@ -55,7 +55,7 @@ public function test_array_representation() $this->assertEquals($expected, $dict->toArray()); } - public function test_allows_checking_attributes() + public function test_allows_checking_attributes(): void { $data = ['lime' => 'tree', 'cherry']; $dict = Dictionary::make($data); diff --git a/tests/unit/MinionTest.php b/tests/unit/MinionTest.php index 4207dc1..e40d371 100644 --- a/tests/unit/MinionTest.php +++ b/tests/unit/MinionTest.php @@ -1,27 +1,27 @@ */ class MinionTest extends PHPUnit\Framework\TestCase { - public function setUp() + public function setUp(): void { $this->m = new Minion(); } - /** - * @expectedException Vinelab\Minion\InvalidProviderException - * @expectedExceptionMessage Provider NonProvider must be an instance of \Vinelab\Minion\Provider - */ - public function test_registering_non_provider_fails() + public function test_registering_non_provider_fails(): void { + $this->expectException(InvalidProviderException::class); + $this->expectExceptionMessage('Provider NonProvider must be an instance of \Vinelab\Minion\Provider'); + $this->m->register('NonProvider'); } - public function test_does_not_register_duplicates() + public function test_does_not_register_duplicates(): void { $this->m->register('AProvider'); $this->m->register('AProvider'); @@ -43,12 +43,12 @@ public function test_default_config() $this->assertEquals($default, $this->m->getConfig()); } - public function test_getting_config_param() + public function test_getting_config_param(): void { $this->assertEquals('minion', $this->m->getConfig('realm')); } - public function test_merging_config() + public function test_merging_config(): void { $options = [ 'realm' => 'secrets', @@ -60,14 +60,14 @@ public function test_merging_config() $this->assertEquals($merged, $this->m->getConfig()); } - public function test_config_tls() + public function test_config_tls(): void { $this->assertEquals(false, $this->m->getConfig('tls')); $this->m->mergeConfig(['tls'=>true]); $this->assertEquals(true, $this->m->getConfig('tls')); } - public function test_config_path() + public function test_config_path(): void { $path = '/websocket'; $this->assertEquals('/ws', $this->m->getConfig('path')); diff --git a/tests/unit/ProviderTest.php b/tests/unit/ProviderTest.php index 30671dd..8bb9474 100644 --- a/tests/unit/ProviderTest.php +++ b/tests/unit/ProviderTest.php @@ -8,18 +8,18 @@ */ class ProviderTest extends UnitTestCase { - public function setUp() + public function setUp(): void { $this->client = new Client('the-realm', []); $this->provider = new ProviderStub($this->client); } - public function tearDown() + public function tearDown(): void { M::close(); } - public function test_initializing_sets_client() + public function test_initializing_sets_client(): void { $getClient = $this->unProtectMethod('getClient', $this->provider); $this->assertEquals($this->client, $getClient->invoke($this->provider));