Skip to content

Commit

Permalink
Merge pull request #25 from assertwell/fix/check-for-runkit-on-functions
Browse files Browse the repository at this point in the history
Mark tests that use defineFunction() or deleteFunction() as skipped if Runkit is unavailable
  • Loading branch information
stevegrunwell authored Apr 15, 2021
2 parents 510f0ab + 054618f commit e397aa7
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 e397aa7

Please sign in to comment.