From deade7398e414dd74f0588bf6a0a591ef4fe007a Mon Sep 17 00:00:00 2001 From: Jwalit Shah Date: Wed, 14 Jun 2023 09:45:33 +1000 Subject: [PATCH] issue#104 skip unit tests that rely on external tools --- tests/wiki_content_mask_test.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/wiki_content_mask_test.php b/tests/wiki_content_mask_test.php index 779673b..4ea98a9 100644 --- a/tests/wiki_content_mask_test.php +++ b/tests/wiki_content_mask_test.php @@ -28,7 +28,11 @@ class wiki_content_mask_test extends \advanced_testcase { * Tests executing the mask, including retaining the wiki links. */ public function test_execute(): void { - global $DB; + global $CFG, $DB; + + if (!file_exists("{$CFG->dirroot}/admin/tool/datamasking/version.php")) { + $this->markTestSkipped('This test uses tool_datamasking, which is not installed. Skipping.'); + } $this->resetAfterTest(); @@ -47,7 +51,7 @@ public function test_execute(): void { '

[[First page]]

[[Second page]]

[[IInd page]]

']); // Run full processing. - $table = new \tool_datamasking\table('ouwiki_versions'); + $table = new tool_datamasking\table('ouwiki_versions'); $table->add(new wiki_content_mask()); $table->execute([], [], new \core\progress\none()); @@ -65,6 +69,11 @@ public function test_execute(): void { * Tests the get_affected_fields function. */ public function test_get_affected_fields(): void { + global $CFG; + + if (!file_exists("{$CFG->dirroot}/admin/tool/datamasking/version.php")) { + $this->markTestSkipped('This test uses tool_datamasking, which is not installed. Skipping.'); + } $mask = new wiki_content_mask(); $this->assertEquals(['xhtml'], $mask->get_affected_fields()); } @@ -73,6 +82,11 @@ public function test_get_affected_fields(): void { * Tests the description text. */ public function test_get_description_text(): void { + global $CFG; + + if (!file_exists("{$CFG->dirroot}/admin/tool/datamasking/version.php")) { + $this->markTestSkipped('This test uses tool_datamasking, which is not installed. Skipping.'); + } $mask = new wiki_content_mask(); $this->assertEquals('Replace with fake text of a similar length, retaining HTML tags and '. '[[wiki page]] links', $mask->get_description_text());