From db5837831bd8536375b86bb892a3f942418fc5f7 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Mon, 23 Sep 2019 15:51:00 -0400 Subject: [PATCH] Fix test warnings due to usage of deprecated assertArraySubset() Also changed app_id to strings where appropriate, in real apps they should be strings when read from environment, not ints. --- tests/ConnectionTest.php | 2 +- .../WebSocketsStatisticsControllerTest.php | 12 ++++++++---- tests/TestCase.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 0c832ad..3a6a974 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -46,7 +46,7 @@ class ConnectionTest extends TestCase $this->pusherServer->onOpen($connection); $this->assertInstanceOf(App::class, $connection->app); - $this->assertSame(1234, $connection->app->id); + $this->assertSame('1234', $connection->app->id); $this->assertSame('TestKey', $connection->app->key); $this->assertSame('TestSecret', $connection->app->secret); $this->assertSame('Test App', $connection->app->name); diff --git a/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php b/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php index 482f50b..bfda847 100644 --- a/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php +++ b/tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php @@ -22,16 +22,20 @@ class WebSocketsStatisticsControllerTest extends TestCase $this->assertCount(1, $entries); - $this->assertArraySubset($this->payload(), $entries->first()->attributesToArray()); + $actual = $entries->first()->attributesToArray(); + foreach ($this->payload() as $key => $value) { + $this->assertArrayHasKey($key, $actual); + $this->assertSame($value, $actual[$key]); + } } protected function payload(): array { return [ 'app_id' => config('websockets.apps.0.id'), - 'peak_connection_count' => 1, - 'websocket_message_count' => 2, - 'api_message_count' => 3, + 'peak_connection_count' => '1', + 'websocket_message_count' => '2', + 'api_message_count' => '3', ]; } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 7b00aed..03896af 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -46,7 +46,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase $app['config']->set('websockets.apps', [ [ 'name' => 'Test App', - 'id' => 1234, + 'id' => '1234', 'key' => 'TestKey', 'secret' => 'TestSecret', 'host' => 'localhost',