Skip to content

Commit ef1be2e

Browse files
jwalitsgbarat87
authored andcommitted
issue #104 skip unit tests that rely on external tools
1 parent 8d1b8f8 commit ef1be2e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/wiki_content_mask_test.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ class wiki_content_mask_test extends \advanced_testcase {
2828
* Tests executing the mask, including retaining the wiki links.
2929
*/
3030
public function test_execute(): void {
31-
global $DB;
31+
global $CFG, $DB;
32+
33+
if (!file_exists("{$CFG->dirroot}/admin/tool/datamasking/version.php")) {
34+
$this->markTestSkipped('This test uses tool_datamasking, which is not installed. Skipping.');
35+
}
3236

3337
$this->resetAfterTest();
3438

@@ -47,7 +51,7 @@ public function test_execute(): void {
4751
'<p>[[First page]]</p><p>[[Second page]]</p><p>[[IInd page]]</p>']);
4852

4953
// Run full processing.
50-
$table = new \tool_datamasking\table('ouwiki_versions');
54+
$table = new tool_datamasking\table('ouwiki_versions');
5155
$table->add(new wiki_content_mask());
5256
$table->execute([], [], new \core\progress\none());
5357

@@ -65,6 +69,11 @@ public function test_execute(): void {
6569
* Tests the get_affected_fields function.
6670
*/
6771
public function test_get_affected_fields(): void {
72+
global $CFG;
73+
74+
if (!file_exists("{$CFG->dirroot}/admin/tool/datamasking/version.php")) {
75+
$this->markTestSkipped('This test uses tool_datamasking, which is not installed. Skipping.');
76+
}
6877
$mask = new wiki_content_mask();
6978
$this->assertEquals(['xhtml'], $mask->get_affected_fields());
7079
}
@@ -73,6 +82,11 @@ public function test_get_affected_fields(): void {
7382
* Tests the description text.
7483
*/
7584
public function test_get_description_text(): void {
85+
global $CFG;
86+
87+
if (!file_exists("{$CFG->dirroot}/admin/tool/datamasking/version.php")) {
88+
$this->markTestSkipped('This test uses tool_datamasking, which is not installed. Skipping.');
89+
}
7690
$mask = new wiki_content_mask();
7791
$this->assertEquals('Replace with fake text of a similar length, retaining HTML tags and '.
7892
'[[wiki page]] links', $mask->get_description_text());

0 commit comments

Comments
 (0)