Skip to content

Skip dump() PHPUnit tests in local Herd environment #7141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2025
Merged
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
8 changes: 8 additions & 0 deletions tests/Cms/Helpers/HelperFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ public function testDeprecated()

public function testDumpOnCli()
{
if (KIRBY_DUMP_OVERRIDDEN === true) {
$this->markTestSkipped('The dump() helper was externally overridden.');
}

$this->assertSame("test\n", dump('test', false));

$this->expectOutputString("test1\ntest2\n");
Expand All @@ -206,6 +210,10 @@ public function testDumpOnCli()

public function testDumpOnServer()
{
if (KIRBY_DUMP_OVERRIDDEN === true) {
$this->markTestSkipped('The dump() helper was externally overridden.');
}

$this->kirby = $this->kirby->clone([
'cli' => false
]);
Expand Down
5 changes: 5 additions & 0 deletions tests/PhpUnitExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;
use ReflectionFunction;

/**
* PHPUnit extension to bootstrap the tests and
Expand Down Expand Up @@ -54,6 +55,10 @@ public static function init(): void

// prevent PHPUnit tests from accessing files outside the repo
Core::$indexRoot = '/dev/null';

// check if the `dump()` helper was overridden, e.g. by Herd
$dump = new ReflectionFunction('dump');
define('KIRBY_DUMP_OVERRIDDEN', str_starts_with($dump->getFileName(), dirname(__DIR__)) === false);
}
}

Expand Down