diff --git a/.github/pr-test-selection.json b/.github/pr-test-selection.json index c28c0fe15..20e5b8daa 100644 --- a/.github/pr-test-selection.json +++ b/.github/pr-test-selection.json @@ -14,6 +14,7 @@ "tests/Unit/V2/EmbeddedHttpSnapshotTest.php", "tests/Unit/V2/ExecutionTracingTest.php", "tests/Unit/V2/ExternalPayloadStorageTest.php", + "tests/Unit/V2/FailureFactoryCliRestoreTest.php", "tests/Unit/V2/LaravelDependencySecurityPolicyTest.php", "tests/Unit/V2/PlatformProtocolSpecsTest.php", "tests/Unit/V2/ReadmeBranchDestinationsTest.php", diff --git a/src/V2/Support/FailureFactory.php b/src/V2/Support/FailureFactory.php index ce2b0b293..4144bc4f1 100644 --- a/src/V2/Support/FailureFactory.php +++ b/src/V2/Support/FailureFactory.php @@ -826,7 +826,6 @@ private static function setThrowableProperty( mixed $value, ): void { $reflectionProperty = new ReflectionProperty($class, $property); - $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($throwable, $value); } diff --git a/tests/Unit/V2/FailureFactoryCliRestoreTest.php b/tests/Unit/V2/FailureFactoryCliRestoreTest.php new file mode 100644 index 000000000..fd5e0071f --- /dev/null +++ b/tests/Unit/V2/FailureFactoryCliRestoreTest.php @@ -0,0 +1,49 @@ + $class, + 'message' => 'example', + 'code' => 17, + 'file' => 'example.php', + 'line' => 1, + 'trace' => [], + 'properties' => [], + ]); + $result[$class] = [$failure::class, $failure->getMessage(), $failure->getCode(), $failure->getFile(), $failure->getLine(), $failure->getTrace()]; +} +echo json_encode($result, JSON_THROW_ON_ERROR); +PHP; + $process = new Process([ + PHP_BINARY, + '-d', 'error_reporting=-1', + '-d', 'display_errors=1', + '-d', 'log_errors=0', + '-r', $script, + dirname(__DIR__, 3) . '/vendor/autoload.php', + ]); + $process->mustRun(); + + $this->assertSame('', $process->getErrorOutput()); + $this->assertSame([ + RuntimeException::class => [RuntimeException::class, 'example', 17, 'example.php', 1, []], + Error::class => [Error::class, 'example', 17, 'example.php', 1, []], + ], json_decode($process->getOutput(), true, flags: JSON_THROW_ON_ERROR)); + } +}