Skip to content
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

issue #104 skip unit tests that rely on external tools #105

Open
wants to merge 1 commit into
base: MOODLE_401_STABLE
Choose a base branch
from
Open
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
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