diff --git a/composer.json b/composer.json index 0ca928e..0bf11d2 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,11 @@ "php": ">=7.1", "clue/socket-raw": "^1.2", "psr/log": "^1.0", - "symfony/process": "^3.3|^4.0|^5.0" + "symfony/process": "^3.3|^4.0|^5.0|^6.0" }, "require-dev": { "monolog/monolog": "^1.23", - "phpunit/phpunit": "^6.5|^7.0" + "phpunit/phpunit": "^6.5|^7.0|^8.0" }, "suggest": { "ext-weakref": "Required to run all the tests" diff --git a/tests/ImplementationTest.php b/tests/ImplementationTest.php index e16726f..7d653e5 100644 --- a/tests/ImplementationTest.php +++ b/tests/ImplementationTest.php @@ -42,7 +42,7 @@ public function can_get_property() { $constants = $this->fs->constants; - $this->assertInternalType('array', $constants); + $this->assertIsArray($constants); } /** @test */ @@ -258,33 +258,30 @@ public function can_receive_heavy_payloads_with_non_ascii_chars() $this->assertStringEndsWith('😘', $payload); } - /** - * @test - * @expectedException \Nesk\Rialto\Exceptions\Node\FatalException - * @expectedExceptionMessage Object.__inexistantMethod__ is not a function - */ + /** @test */ public function node_crash_throws_a_fatal_exception() { + $this->expectException(Node\FatalException::class); + $this->expectExceptionMessage('Object.__inexistantMethod__ is not a function'); + $this->fs->__inexistantMethod__(); } - /** - * @test - * @expectedException \Nesk\Rialto\Exceptions\Node\Exception - * @expectedExceptionMessage Object.__inexistantMethod__ is not a function - */ + /** @test */ public function can_catch_errors() { + $this->expectException(Node\Exception::class); + $this->expectExceptionMessage('Object.__inexistantMethod__ is not a function'); + $this->fs->tryCatch->__inexistantMethod__(); } - /** - * @test - * @expectedException \Nesk\Rialto\Exceptions\Node\FatalException - * @expectedExceptionMessage Object.__inexistantMethod__ is not a function - */ + /** @test */ public function catching_a_node_exception_doesnt_catch_fatal_exceptions() { + $this->expectException(Node\FatalException::class); + $this->expectExceptionMessage('Object.__inexistantMethod__ is not a function'); + try { $this->fs->__inexistantMethod__(); } catch (Node\Exception $exception) { @@ -323,13 +320,12 @@ public function node_current_working_directory_is_the_same_as_php() $this->assertNull($result); } - /** - * @test - * @expectedException \Symfony\Component\Process\Exception\ProcessFailedException - * @expectedExceptionMessageRegExp /Error Output:\n=+\n.*__inexistant_process__.*not found/ - */ + /** @test */ public function executable_path_option_changes_the_process_prefix() { + $this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class); + $this->expectExceptionMessageMatches('/Error Output:\n=+\n.*__inexistant_process__.*not found/'); + new FsWithProcessDelegation(['executable_path' => '__inexistant_process__']); } @@ -346,7 +342,7 @@ public function idle_timeout_option_closes_node_once_timer_is_reached() sleep(1); $this->expectException(\Nesk\Rialto\Exceptions\IdleTimeoutException::class); - $this->expectExceptionMessageRegExp('/^The idle timeout \(0\.500 seconds\) has been exceeded/'); + $this->expectExceptionMessageMatches('/^The idle timeout \(0\.500 seconds\) has been exceeded/'); $this->fs->constants; } @@ -354,11 +350,12 @@ public function idle_timeout_option_closes_node_once_timer_is_reached() /** * @test * @dontPopulateProperties fs - * @expectedException \Nesk\Rialto\Exceptions\ReadSocketTimeoutException - * @expectedExceptionMessageRegExp /^The timeout \(0\.010 seconds\) has been exceeded/ */ public function read_timeout_option_throws_an_exception_on_long_actions() { + $this->expectException(\Nesk\Rialto\Exceptions\ReadSocketTimeoutException::class); + $this->expectExceptionMessageMatches('/^The timeout \(0\.010 seconds\) has been exceeded/'); + $this->fs = new FsWithProcessDelegation(['read_timeout' => 0.01]); $this->fs->wait(20); @@ -447,13 +444,7 @@ public function process_status_is_tracked() /** @test */ public function process_is_properly_shutdown_when_there_are_no_more_references() { - if (!class_exists('WeakRef')) { - $this->markTestSkipped( - 'This test requires weak references (unavailable for PHP 7.3): http://php.net/weakref/' - ); - } - - $ref = new \WeakRef($this->fs->getProcessSupervisor()); + $ref = \WeakReference::create($this->fs->getProcessSupervisor()); $resource = $this->fs->readFileSync($this->filePath); @@ -462,7 +453,7 @@ public function process_is_properly_shutdown_when_there_are_no_more_references() $this->fs = null; unset($resource); - $this->assertFalse($ref->valid()); + $this->assertNull($ref->get()); } /**