Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Add support for symfony/process 6 #40

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
55 changes: 23 additions & 32 deletions tests/ImplementationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function can_get_property()
{
$constants = $this->fs->constants;

$this->assertInternalType('array', $constants);
$this->assertIsArray($constants);
}

/** @test */
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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__']);
}

Expand All @@ -346,19 +342,20 @@ 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;
}

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

Expand All @@ -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());
}

/**
Expand Down