From 79aa95fa708ccf21bd080c2711d8d293249510ae Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sun, 1 Mar 2020 13:16:06 +0800 Subject: [PATCH] Fixes 5.5 compatibility. Signed-off-by: Mior Muhammad Zaki --- composer.json | 4 ++-- tests/Feature/StreamServiceProviderTest.php | 3 +-- tests/Unit/Log/ConsoleTest.php | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 94a2293..be7401d 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ }, "require": { "php": ">=7.1", - "illuminate/support": "^5.6 || ^6.0 || ^7.0", + "illuminate/support": "^5.5 || ^6.0 || ^7.0", "jakub-onderka/php-console-color": "~0.2", "react/stream": "^1.1" }, "require-dev": { "mockery/mockery": "^1.3.1", - "orchestra/testbench": "^3.6 || ^4.0 || ^5.0" + "orchestra/testbench": "^3.5 || ^4.0 || ^5.0" }, "config": { "sort-packages": true diff --git a/tests/Feature/StreamServiceProviderTest.php b/tests/Feature/StreamServiceProviderTest.php index b883d66..096efeb 100644 --- a/tests/Feature/StreamServiceProviderTest.php +++ b/tests/Feature/StreamServiceProviderTest.php @@ -6,7 +6,6 @@ use React\Stream\ThroughStream; use React\Stream\WritableResourceStream; use React\Stream\WritableStreamInterface; -use SebastianBergmann\Environment\OperatingSystem; class StreamServiceProviderTest extends TestCase { @@ -20,7 +19,7 @@ public function it_provides_proper_services() $writable = $this->app->make(WritableStreamInterface::class); - if ((new OperatingSystem())->getFamily() === 'Windows') { + if (DIRECTORY_SEPARATOR !== '/') { $this->assertInstanceOf(ThroughStream::class, $writable); } else { $this->assertInstanceOf(WritableResourceStream::class, $writable); diff --git a/tests/Unit/Log/ConsoleTest.php b/tests/Unit/Log/ConsoleTest.php index d9dfc5c..053f706 100644 --- a/tests/Unit/Log/ConsoleTest.php +++ b/tests/Unit/Log/ConsoleTest.php @@ -39,7 +39,7 @@ public function it_can_write_info() $stub = new Console($writer, $styler); $writer->shouldReceive('write')->once()->with(m::type('String'))->andReturnUsing(function ($message) { - $this->assertStringContainsString('Hello world', $message); + $this->expectContains('Hello world', $message); }); $stub->info('Hello world'); @@ -54,7 +54,7 @@ public function it_can_write_warn() $stub = new Console($writer, $styler); $writer->shouldReceive('write')->once()->with(m::type('String'))->andReturnUsing(function ($message) { - $this->assertStringContainsString('Hello world', $message); + $this->expectContains('Hello world', $message); }); $stub->warn('Hello world'); @@ -69,9 +69,18 @@ public function it_can_write_error() $stub = new Console($writer, $styler); $writer->shouldReceive('write')->once()->with(m::type('String'))->andReturnUsing(function ($message) { - $this->assertStringContainsString('Hello world', $message); + $this->expectContains('Hello world', $message); }); $stub->error('Hello world'); } + + public function expectContains(string $needle, string $haystack): void + { + if (\method_exists($this, 'assertStringContainsString')) { + $this->assertStringContainsString($needle, $haystack); + } else { + $this->assertContains($needle, $haystack); + } + } }