Skip to content

Commit

Permalink
issue#104 skip unit tests that rely on external tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jwalits authored and gbarat87 committed Apr 12, 2024
1 parent 8d1b8f8 commit deade73
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/wiki_content_mask_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

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

// 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());

Expand All @@ -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());
}
Expand All @@ -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());
Expand Down

0 comments on commit deade73

Please sign in to comment.