Skip to content

update deprecated and broken tests #53

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

Open
wants to merge 2 commits into
base: MOODLE_39_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
20 changes: 10 additions & 10 deletions tests/filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function test_empty_image() {
];
foreach ($sizes as $size) {
$emptyimage = phpunit_util::call_internal_method($filter, 'empty_image', $size, get_class($filter));
$this->assertContains('width="'.$size[0].'" height="'.$size[1].'"', $emptyimage);
$this->assertStringContainsString('width="'.$size[0].'" height="'.$size[1].'"', $emptyimage);
}
}

Expand Down Expand Up @@ -271,7 +271,7 @@ public function test_apply_loadonvisible() {
// Test filter plugin img, lazy load.
$regex = '/img data-loadonvisible="'.str_replace('~pathid~', '(?:[0-9]*)', preg_quote($loadonvisibleurl, '/')).'/';
$this->assertRegExp($regex, $str);
$this->assertContains('src="data:image/svg+xml;utf8,', $str);
$this->assertStringContainsString('src="data:image/svg+xml;utf8,', $str);

}

Expand Down Expand Up @@ -346,29 +346,29 @@ public function test_filter() {
$filter = new filter_imageopt($context, []);
$filtered = $filter->filter($labeltxt);
$prefilterurl = $CFG->wwwroot.'/pluginfile.php/'.$context->id.'/mod_label/intro/0/testpng_2880x1800.png';
$this->assertContains($prefilterurl, $labeltxt);
$this->assertStringContainsString($prefilterurl, $labeltxt);
$postfilterurl = $this->filter_imageopt_url_from_file($file, $maxwidth);
$regex = '/src="'.str_replace('~pathid~', '(?:[0-9]*)', preg_quote($postfilterurl, '/')).'/';
$this->assertRegExp($regex, $filtered);

// We need a space before src so it doesn't trigger on original-src.
$this->assertNotContains(' src="'.$prefilterurl, $filtered);
$this->assertNotContains('data-loadonvisible="'.$postfilterurl, $filtered);
$this->assertNotContains('data-loadonvisible="'.$prefilterurl, $filtered);
$this->assertStringNotContainsString(' src="'.$prefilterurl, $filtered);
$this->assertStringNotContainsString('data-loadonvisible="'.$postfilterurl, $filtered);
$this->assertStringNotContainsString('data-loadonvisible="'.$prefilterurl, $filtered);

// Test filter plugin img, lazy load.
set_config('loadonvisible', '0', 'filter_imageopt');
$filter = new filter_imageopt($context, []);
$filtered = $filter->filter($labeltxt);
$prefilterurl = $CFG->wwwroot.'/pluginfile.php/'.$context->id.'/mod_label/intro/0/testpng_2880x1800.png';
$this->assertContains($prefilterurl, $labeltxt);
$this->assertStringContainsString($prefilterurl, $labeltxt);
$postfilterurl = $this->filter_imageopt_url_from_file($file, $maxwidth);

$regex = '/data-loadonvisible="'.str_replace('~pathid~', '(?:[0-9]*)', preg_quote($postfilterurl, '/')).'/';
$this->assertRegExp($regex, $filtered);

$this->assertNotContains('data-loadonvisible="'.$prefilterurl, $filtered);
$this->assertNotContains('src="'.$postfilterurl, $filtered);
$this->assertNotContains('src="'.$prefilterurl, $filtered);
$this->assertStringNotContainsString('data-loadonvisible="'.$prefilterurl, $filtered);
$this->assertStringNotContainsString('src="'.$postfilterurl, $filtered);
$this->assertStringNotContainsString('src="'.$prefilterurl, $filtered);
}
}