Skip to content

Commit

Permalink
Mark tests that use defineFunction() or deleteFunction() as skipped i…
Browse files Browse the repository at this point in the history
…f 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.
  • Loading branch information
stevegrunwell committed Apr 15, 2021
1 parent 510f0ab commit 054618f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 054618f

Please sign in to comment.