From 7a7ff97e630238bc09cd7cb10bd61561984852ed Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 20 Oct 2025 10:54:12 +0200 Subject: [PATCH] Unbreak test failure in Helpindex test We need to mock the call to `is_readable`, since the file requested in the test does not actually exist in the file system. --- tests/unit/Widget/HelpindexTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/Widget/HelpindexTest.php b/tests/unit/Widget/HelpindexTest.php index 87042c559..b3a93cad9 100644 --- a/tests/unit/Widget/HelpindexTest.php +++ b/tests/unit/Widget/HelpindexTest.php @@ -37,7 +37,7 @@ class HelpindexTest extends \Zotlabs\Tests\Unit\Module\TestCase { $this->output = ''; } - public function test_loading_toc(): void { + public function test_loading_toc_from_html(): void { // Stub `file_get_contents` to plant our own content. $fgc_stub = $this->getFunctionMock('Zotlabs\Widget', 'file_get_contents'); $fgc_stub @@ -45,6 +45,12 @@ class HelpindexTest extends \Zotlabs\Tests\Unit\Module\TestCase { ->with($this->equalTo('doc/en/toc.html')) ->willReturn('toc'); + // Stub `is_readable` to only return true for the english toc file + $is_readable_stub = $this->getFunctionMock('Zotlabs\Widget', 'is_readable'); + $is_readable_stub + ->expects($this->any()) + ->willReturnCallback(fn (string $path) => $path === 'doc/en/toc.html' ); + // Stub `file_exists` to only return true for the english toc file $fe_stub = $this->getFunctionMock('Zotlabs\Lib\Traits', 'file_exists'); $fe_stub @@ -53,7 +59,6 @@ class HelpindexTest extends \Zotlabs\Tests\Unit\Module\TestCase { $this->render_widget(); $this->assertOutputContains('toc'); - //$this->assertOutputContains('Help Content'); } public function test_that_result_is_empty_when_toc_not_present(): void {