From 054618fc025206f85c3f37ae43470678892f9bb2 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Thu, 15 Apr 2021 14:35:29 -0400 Subject: [PATCH] Mark tests that use defineFunction() or deleteFunction() as skipped if Runkit is unavailable Similar checks are used elsewhere for Runkit-dependent methods, as this prevents tests from erroring due to Runkit not being present. Fixes #24. --- src/Functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Functions.php b/src/Functions.php index 37a053a..0bc6a6f 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -56,6 +56,10 @@ protected function restoreFunctions() */ protected function defineFunction($name, \Closure $closure) { + if (! Runkit::isAvailable()) { + $this->markTestSkipped('defineFunction() requires Runkit be available, skipping.'); + } + if (function_exists($name)) { throw new FunctionExistsException(sprintf( 'Function %1$s() already exists. You may redefine it using %2$s::redefineFunction() instead.', @@ -130,6 +134,10 @@ protected function deleteFunction($name) return $this; } + if (! Runkit::isAvailable()) { + $this->markTestSkipped('deleteFunction() requires Runkit be available, skipping.'); + } + $namespaced = Runkit::makeNamespaced($name); if (! Runkit::function_rename($name, $namespaced)) {