Merge branch 'MDL-49360-28' of git://github.com/lameze/moodle into MOODLE_28_STABLE
[moodle.git] / lib / tests / weblib_test.php
blob513ee7b43baf54e13a3504e3399dbcbd68d81ab6
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Weblib tests.
20 * @package core
21 * @category phpunit
22 * @copyright &copy; 2006 The Open University
23 * @author T.J.Hunt@open.ac.uk
24 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
27 defined('MOODLE_INTERNAL') || die();
30 class core_weblib_testcase extends advanced_testcase {
32 public function test_format_string() {
33 global $CFG;
35 // Ampersands.
36 $this->assertSame("&amp; &amp;&amp;&amp;&amp;&amp; &amp;&amp;", format_string("& &&&&& &&"));
37 $this->assertSame("ANother &amp; &amp;&amp;&amp;&amp;&amp; Category", format_string("ANother & &&&&& Category"));
38 $this->assertSame("ANother &amp; &amp;&amp;&amp;&amp;&amp; Category", format_string("ANother & &&&&& Category", true));
39 $this->assertSame("Nick's Test Site &amp; Other things", format_string("Nick's Test Site & Other things", true));
41 // String entities.
42 $this->assertSame("&quot;", format_string("&quot;"));
44 // Digital entities.
45 $this->assertSame("&11234;", format_string("&11234;"));
47 // Unicode entities.
48 $this->assertSame("&#4475;", format_string("&#4475;"));
50 // < and > signs.
51 $originalformatstringstriptags = $CFG->formatstringstriptags;
53 $CFG->formatstringstriptags = false;
54 $this->assertSame('x &lt; 1', format_string('x < 1'));
55 $this->assertSame('x &gt; 1', format_string('x > 1'));
56 $this->assertSame('x &lt; 1 and x &gt; 0', format_string('x < 1 and x > 0'));
58 $CFG->formatstringstriptags = true;
59 $this->assertSame('x &lt; 1', format_string('x < 1'));
60 $this->assertSame('x &gt; 1', format_string('x > 1'));
61 $this->assertSame('x &lt; 1 and x &gt; 0', format_string('x < 1 and x > 0'));
63 $CFG->formatstringstriptags = $originalformatstringstriptags;
66 public function test_s() {
67 // Special cases.
68 $this->assertSame('0', s(0));
69 $this->assertSame('0', s('0'));
70 $this->assertSame('0', s(false));
71 $this->assertSame('', s(null));
73 // Normal cases.
74 $this->assertSame('This Breaks &quot; Strict', s('This Breaks " Strict'));
75 $this->assertSame('This Breaks &lt;a&gt;&quot; Strict&lt;/a&gt;', s('This Breaks <a>" Strict</a>'));
77 // Unicode characters.
78 $this->assertSame('Café', s('Café'));
79 $this->assertSame('一, 二, 三', s('一, 二, 三'));
81 // Don't escape already-escaped numeric entities. (Note, this behaviour
82 // may not be desirable. Perhaps we should remove these tests and that
83 // functionality, but we can only do that if we understand why it was added.)
84 $this->assertSame('An entity: &#x09ff;.', s('An entity: &#x09ff;.'));
85 $this->assertSame('An entity: &#1073;.', s('An entity: &#1073;.'));
86 $this->assertSame('An entity: &amp;amp;.', s('An entity: &amp;.'));
87 $this->assertSame('Not an entity: &amp;amp;#x09ff;.', s('Not an entity: &amp;#x09ff;.'));
90 public function test_format_text_email() {
91 $this->assertSame("This is a TEST",
92 format_text_email('<p>This is a <strong>test</strong></p>', FORMAT_HTML));
93 $this->assertSame("This is a TEST",
94 format_text_email('<p class="frogs">This is a <strong class=\'fishes\'>test</strong></p>', FORMAT_HTML));
95 $this->assertSame('& so is this',
96 format_text_email('&amp; so is this', FORMAT_HTML));
97 $this->assertSame('Two bullets: '.core_text::code2utf8(8226).' *',
98 format_text_email('Two bullets: &#x2022; &#8226;', FORMAT_HTML));
99 $this->assertSame(core_text::code2utf8(0x7fd2).core_text::code2utf8(0x7fd2),
100 format_text_email('&#x7fd2;&#x7FD2;', FORMAT_HTML));
103 public function test_obfuscate_email() {
104 $email = 'some.user@example.com';
105 $obfuscated = obfuscate_email($email);
106 $this->assertNotSame($email, $obfuscated);
107 $back = core_text::entities_to_utf8(urldecode($email), true);
108 $this->assertSame($email, $back);
111 public function test_obfuscate_text() {
112 $text = 'Žluťoučký koníček 32131';
113 $obfuscated = obfuscate_text($text);
114 $this->assertNotSame($text, $obfuscated);
115 $back = core_text::entities_to_utf8($obfuscated, true);
116 $this->assertSame($text, $back);
119 public function test_highlight() {
120 $this->assertSame('This is <span class="highlight">good</span>',
121 highlight('good', 'This is good'));
123 $this->assertSame('<span class="highlight">span</span>',
124 highlight('SpaN', 'span'));
126 $this->assertSame('<span class="highlight">SpaN</span>',
127 highlight('span', 'SpaN'));
129 $this->assertSame('<span><span class="highlight">span</span></span>',
130 highlight('span', '<span>span</span>'));
132 $this->assertSame('He <span class="highlight">is</span> <span class="highlight">good</span>',
133 highlight('good is', 'He is good'));
135 $this->assertSame('This is <span class="highlight">good</span>',
136 highlight('+good', 'This is good'));
138 $this->assertSame('This is good',
139 highlight('-good', 'This is good'));
141 $this->assertSame('This is goodness',
142 highlight('+good', 'This is goodness'));
144 $this->assertSame('This is <span class="highlight">good</span>ness',
145 highlight('good', 'This is goodness'));
147 $this->assertSame('<p><b>test</b> <b>1</b></p><p><b>1</b></p>',
148 highlight('test 1', '<p>test 1</p><p>1</p>', false, '<b>', '</b>'));
150 $this->assertSame('<p><b>test</b> <b>1</b></p><p><b>1</b></p>',
151 highlight('test +1', '<p>test 1</p><p>1</p>', false, '<b>', '</b>'));
153 $this->assertSame('<p><b>test</b> 1</p><p>1</p>',
154 highlight('test -1', '<p>test 1</p><p>1</p>', false, '<b>', '</b>'));
157 public function test_replace_ampersands() {
158 $this->assertSame("This &amp; that &nbsp;", replace_ampersands_not_followed_by_entity("This & that &nbsp;"));
159 $this->assertSame("This &amp;nbsp that &nbsp;", replace_ampersands_not_followed_by_entity("This &nbsp that &nbsp;"));
162 public function test_strip_links() {
163 $this->assertSame('this is a link', strip_links('this is a <a href="http://someaddress.com/query">link</a>'));
166 public function test_wikify_links() {
167 $this->assertSame('this is a link [ http://someaddress.com/query ]', wikify_links('this is a <a href="http://someaddress.com/query">link</a>'));
171 * Test basic moodle_url construction.
173 public function test_moodle_url_constructor() {
174 global $CFG;
176 $url = new moodle_url('/index.php');
177 $this->assertSame($CFG->wwwroot.'/index.php', $url->out());
179 $url = new moodle_url('/index.php', array());
180 $this->assertSame($CFG->wwwroot.'/index.php', $url->out());
182 $url = new moodle_url('/index.php', array('id' => 2));
183 $this->assertSame($CFG->wwwroot.'/index.php?id=2', $url->out());
185 $url = new moodle_url('/index.php', array('id' => 'two'));
186 $this->assertSame($CFG->wwwroot.'/index.php?id=two', $url->out());
188 $url = new moodle_url('/index.php', array('id' => 1, 'cid' => '2'));
189 $this->assertSame($CFG->wwwroot.'/index.php?id=1&amp;cid=2', $url->out());
190 $this->assertSame($CFG->wwwroot.'/index.php?id=1&cid=2', $url->out(false));
192 $url = new moodle_url('/index.php', null, 'test');
193 $this->assertSame($CFG->wwwroot.'/index.php#test', $url->out());
195 $url = new moodle_url('/index.php', array('id' => 2), 'test');
196 $this->assertSame($CFG->wwwroot.'/index.php?id=2#test', $url->out());
200 * Tests moodle_url::get_path().
202 public function test_moodle_url_get_path() {
203 $url = new moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1');
204 $this->assertSame('/my/file/is/here.txt', $url->get_path());
206 $url = new moodle_url('http://www.example.org/');
207 $this->assertSame('/', $url->get_path());
209 $url = new moodle_url('http://www.example.org/pluginfile.php/slash/arguments');
210 $this->assertSame('/pluginfile.php/slash/arguments', $url->get_path());
211 $this->assertSame('/pluginfile.php', $url->get_path(false));
214 public function test_moodle_url_round_trip() {
215 $strurl = 'http://moodle.org/course/view.php?id=5';
216 $url = new moodle_url($strurl);
217 $this->assertSame($strurl, $url->out(false));
219 $strurl = 'http://moodle.org/user/index.php?contextid=53&sifirst=M&silast=D';
220 $url = new moodle_url($strurl);
221 $this->assertSame($strurl, $url->out(false));
225 * Test Moodle URL objects created with a param with empty value.
227 public function test_moodle_url_empty_param_values() {
228 $strurl = 'http://moodle.org/course/view.php?id=0';
229 $url = new moodle_url($strurl, array('id' => 0));
230 $this->assertSame($strurl, $url->out(false));
232 $strurl = 'http://moodle.org/course/view.php?id';
233 $url = new moodle_url($strurl, array('id' => false));
234 $this->assertSame($strurl, $url->out(false));
236 $strurl = 'http://moodle.org/course/view.php?id';
237 $url = new moodle_url($strurl, array('id' => null));
238 $this->assertSame($strurl, $url->out(false));
240 $strurl = 'http://moodle.org/course/view.php?id';
241 $url = new moodle_url($strurl, array('id' => ''));
242 $this->assertSame($strurl, $url->out(false));
244 $strurl = 'http://moodle.org/course/view.php?id';
245 $url = new moodle_url($strurl);
246 $this->assertSame($strurl, $url->out(false));
249 public function test_moodle_url_round_trip_array_params() {
250 $strurl = 'http://example.com/?a%5B1%5D=1&a%5B2%5D=2';
251 $url = new moodle_url($strurl);
252 $this->assertSame($strurl, $url->out(false));
254 $url = new moodle_url('http://example.com/?a[1]=1&a[2]=2');
255 $this->assertSame($strurl, $url->out(false));
257 // For un-keyed array params, we expect 0..n keys to be returned.
258 $strurl = 'http://example.com/?a%5B0%5D=0&a%5B1%5D=1';
259 $url = new moodle_url('http://example.com/?a[]=0&a[]=1');
260 $this->assertSame($strurl, $url->out(false));
263 public function test_compare_url() {
264 $url1 = new moodle_url('index.php', array('var1' => 1, 'var2' => 2));
265 $url2 = new moodle_url('index2.php', array('var1' => 1, 'var2' => 2, 'var3' => 3));
267 $this->assertFalse($url1->compare($url2, URL_MATCH_BASE));
268 $this->assertFalse($url1->compare($url2, URL_MATCH_PARAMS));
269 $this->assertFalse($url1->compare($url2, URL_MATCH_EXACT));
271 $url2 = new moodle_url('index.php', array('var1' => 1, 'var3' => 3));
273 $this->assertTrue($url1->compare($url2, URL_MATCH_BASE));
274 $this->assertFalse($url1->compare($url2, URL_MATCH_PARAMS));
275 $this->assertFalse($url1->compare($url2, URL_MATCH_EXACT));
277 $url2 = new moodle_url('index.php', array('var1' => 1, 'var2' => 2, 'var3' => 3));
279 $this->assertTrue($url1->compare($url2, URL_MATCH_BASE));
280 $this->assertTrue($url1->compare($url2, URL_MATCH_PARAMS));
281 $this->assertFalse($url1->compare($url2, URL_MATCH_EXACT));
283 $url2 = new moodle_url('index.php', array('var2' => 2, 'var1' => 1));
285 $this->assertTrue($url1->compare($url2, URL_MATCH_BASE));
286 $this->assertTrue($url1->compare($url2, URL_MATCH_PARAMS));
287 $this->assertTrue($url1->compare($url2, URL_MATCH_EXACT));
289 $url1->set_anchor('test');
290 $this->assertTrue($url1->compare($url2, URL_MATCH_BASE));
291 $this->assertTrue($url1->compare($url2, URL_MATCH_PARAMS));
292 $this->assertFalse($url1->compare($url2, URL_MATCH_EXACT));
294 $url2->set_anchor('test');
295 $this->assertTrue($url1->compare($url2, URL_MATCH_BASE));
296 $this->assertTrue($url1->compare($url2, URL_MATCH_PARAMS));
297 $this->assertTrue($url1->compare($url2, URL_MATCH_EXACT));
300 public function test_out_as_local_url() {
301 global $CFG;
302 // Test http url.
303 $url1 = new moodle_url('/lib/tests/weblib_test.php');
304 $this->assertSame('/lib/tests/weblib_test.php', $url1->out_as_local_url());
306 // Test https url.
307 $httpswwwroot = str_replace("http://", "https://", $CFG->wwwroot);
308 $url2 = new moodle_url($httpswwwroot.'/login/profile.php');
309 $this->assertSame('/login/profile.php', $url2->out_as_local_url());
311 // Test http url matching wwwroot.
312 $url3 = new moodle_url($CFG->wwwroot);
313 $this->assertSame('', $url3->out_as_local_url());
315 // Test http url matching wwwroot ending with slash (/).
316 $url3 = new moodle_url($CFG->wwwroot.'/');
317 $this->assertSame('/', $url3->out_as_local_url());
321 * @expectedException coding_exception
322 * @return void
324 public function test_out_as_local_url_error() {
325 $url2 = new moodle_url('http://www.google.com/lib/tests/weblib_test.php');
326 $url2->out_as_local_url();
330 * You should get error with modified url
332 * @expectedException coding_exception
333 * @return void
335 public function test_modified_url_out_as_local_url_error() {
336 global $CFG;
338 $modifiedurl = $CFG->wwwroot.'1';
339 $url3 = new moodle_url($modifiedurl.'/login/profile.php');
340 $url3->out_as_local_url();
344 * Try get local url from external https url and you should get error
346 * @expectedException coding_exception
348 public function test_https_out_as_local_url_error() {
349 $url4 = new moodle_url('https://www.google.com/lib/tests/weblib_test.php');
350 $url4->out_as_local_url();
353 public function test_moodle_url_get_scheme() {
354 // Should return the scheme only.
355 $url = new moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1');
356 $this->assertSame('http', $url->get_scheme());
358 // Should work for secure URLs.
359 $url = new moodle_url('https://www.example.org:447/my/file/is/here.txt?really=1');
360 $this->assertSame('https', $url->get_scheme());
362 // Should return an empty string if no scheme is specified.
363 $url = new moodle_url('www.example.org:447/my/file/is/here.txt?really=1');
364 $this->assertSame('', $url->get_scheme());
367 public function test_moodle_url_get_host() {
368 // Should return the host part only.
369 $url = new moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1');
370 $this->assertSame('www.example.org', $url->get_host());
373 public function test_moodle_url_get_port() {
374 // Should return the port if one provided.
375 $url = new moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1');
376 $this->assertSame(447, $url->get_port());
378 // Should return an empty string if port not specified.
379 $url = new moodle_url('http://www.example.org/some/path/here.php');
380 $this->assertSame('', $url->get_port());
383 public function test_clean_text() {
384 $text = "lala <applet>xx</applet>";
385 $this->assertSame($text, clean_text($text, FORMAT_PLAIN));
386 $this->assertSame('lala xx', clean_text($text, FORMAT_MARKDOWN));
387 $this->assertSame('lala xx', clean_text($text, FORMAT_MOODLE));
388 $this->assertSame('lala xx', clean_text($text, FORMAT_HTML));
391 public function test_qualified_me() {
392 global $PAGE, $FULLME, $CFG;
393 $this->resetAfterTest();
395 $PAGE = new moodle_page();
397 $FULLME = $CFG->wwwroot.'/course/view.php?id=1&xx=yy';
398 $this->assertSame($FULLME, qualified_me());
400 $PAGE->set_url('/course/view.php', array('id'=>1));
401 $this->assertSame($CFG->wwwroot.'/course/view.php?id=1', qualified_me());
404 public function test_null_progres_trace() {
405 $this->resetAfterTest(false);
407 $trace = new null_progress_trace();
408 $trace->output('do');
409 $trace->output('re', 1);
410 $trace->output('mi', 2);
411 $trace->finished();
412 $output = ob_get_contents();
413 $this->assertSame('', $output);
414 $this->expectOutputString('');
417 public function test_text_progres_trace() {
418 $this->resetAfterTest(false);
420 $trace = new text_progress_trace();
421 $trace->output('do');
422 $trace->output('re', 1);
423 $trace->output('mi', 2);
424 $trace->finished();
425 $this->expectOutputString("do\n re\n mi\n");
428 public function test_html_progres_trace() {
429 $this->resetAfterTest(false);
431 $trace = new html_progress_trace();
432 $trace->output('do');
433 $trace->output('re', 1);
434 $trace->output('mi', 2);
435 $trace->finished();
436 $this->expectOutputString("<p>do</p>\n<p>&#160;&#160;re</p>\n<p>&#160;&#160;&#160;&#160;mi</p>\n");
439 public function test_html_list_progress_trace() {
440 $this->resetAfterTest(false);
442 $trace = new html_list_progress_trace();
443 $trace->output('do');
444 $trace->output('re', 1);
445 $trace->output('mi', 2);
446 $trace->finished();
447 $this->expectOutputString("<ul>\n<li>do<ul>\n<li>re<ul>\n<li>mi</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n");
450 public function test_progres_trace_buffer() {
451 $this->resetAfterTest(false);
453 $trace = new progress_trace_buffer(new html_progress_trace());
454 ob_start();
455 $trace->output('do');
456 $trace->output('re', 1);
457 $trace->output('mi', 2);
458 $trace->finished();
459 $output = ob_get_contents();
460 ob_end_clean();
461 $this->assertSame("<p>do</p>\n<p>&#160;&#160;re</p>\n<p>&#160;&#160;&#160;&#160;mi</p>\n", $output);
462 $this->assertSame($output, $trace->get_buffer());
464 $trace = new progress_trace_buffer(new html_progress_trace(), false);
465 $trace->output('do');
466 $trace->output('re', 1);
467 $trace->output('mi', 2);
468 $trace->finished();
469 $this->assertSame("<p>do</p>\n<p>&#160;&#160;re</p>\n<p>&#160;&#160;&#160;&#160;mi</p>\n", $trace->get_buffer());
470 $this->assertSame("<p>do</p>\n<p>&#160;&#160;re</p>\n<p>&#160;&#160;&#160;&#160;mi</p>\n", $trace->get_buffer());
471 $trace->reset_buffer();
472 $this->assertSame('', $trace->get_buffer());
473 $this->expectOutputString('');
476 public function test_combined_progres_trace() {
477 $this->resetAfterTest(false);
479 $trace1 = new progress_trace_buffer(new html_progress_trace(), false);
480 $trace2 = new progress_trace_buffer(new text_progress_trace(), false);
482 $trace = new combined_progress_trace(array($trace1, $trace2));
483 $trace->output('do');
484 $trace->output('re', 1);
485 $trace->output('mi', 2);
486 $trace->finished();
487 $this->assertSame("<p>do</p>\n<p>&#160;&#160;re</p>\n<p>&#160;&#160;&#160;&#160;mi</p>\n", $trace1->get_buffer());
488 $this->assertSame("do\n re\n mi\n", $trace2->get_buffer());
489 $this->expectOutputString('');
492 public function test_set_debugging() {
493 global $CFG;
495 $this->resetAfterTest();
497 $this->assertEquals(DEBUG_DEVELOPER, $CFG->debug);
498 $this->assertTrue($CFG->debugdeveloper);
499 $this->assertNotEmpty($CFG->debugdisplay);
501 set_debugging(DEBUG_DEVELOPER, true);
502 $this->assertEquals(DEBUG_DEVELOPER, $CFG->debug);
503 $this->assertTrue($CFG->debugdeveloper);
504 $this->assertNotEmpty($CFG->debugdisplay);
506 set_debugging(DEBUG_DEVELOPER, false);
507 $this->assertEquals(DEBUG_DEVELOPER, $CFG->debug);
508 $this->assertTrue($CFG->debugdeveloper);
509 $this->assertEmpty($CFG->debugdisplay);
511 set_debugging(-1);
512 $this->assertEquals(-1, $CFG->debug);
513 $this->assertTrue($CFG->debugdeveloper);
515 set_debugging(DEBUG_ALL);
516 $this->assertEquals(DEBUG_ALL, $CFG->debug);
517 $this->assertFalse($CFG->debugdeveloper);
519 set_debugging(DEBUG_NORMAL);
520 $this->assertEquals(DEBUG_NORMAL, $CFG->debug);
521 $this->assertFalse($CFG->debugdeveloper);
523 set_debugging(DEBUG_MINIMAL);
524 $this->assertEquals(DEBUG_MINIMAL, $CFG->debug);
525 $this->assertFalse($CFG->debugdeveloper);
527 set_debugging(DEBUG_NONE);
528 $this->assertEquals(DEBUG_NONE, $CFG->debug);
529 $this->assertFalse($CFG->debugdeveloper);
532 public function test_strip_pluginfile_content() {
533 $source = <<<SOURCE
534 Hello!
536 I'm writing to you from the Moodle Majlis in Muscat, Oman, where we just had several days of Moodle community goodness.
538 URL outside a tag: https://moodle.org/logo/logo-240x60.gif
539 Plugin url outside a tag: @@PLUGINFILE@@/logo-240x60.gif
541 External link 1:<img src='https://moodle.org/logo/logo-240x60.gif' alt='Moodle'/>
542 External link 2:<img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif"/>
543 Internal link 1:<img src='@@PLUGINFILE@@/logo-240x60.gif' alt='Moodle'/>
544 Internal link 2:<img alt="Moodle" src="@@PLUGINFILE@@logo-240x60.gif"/>
545 Anchor link 1:<a href="@@PLUGINFILE@@logo-240x60.gif" alt="bananas">Link text</a>
546 Anchor link 2:<a title="bananas" href="../logo-240x60.gif">Link text</a>
547 Anchor + ext. img:<a title="bananas" href="../logo-240x60.gif"><img alt="Moodle" src="@@PLUGINFILE@@logo-240x60.gif"/></a>
548 Ext. anchor + img:<a href="@@PLUGINFILE@@logo-240x60.gif"><img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif"/></a>
549 SOURCE;
550 $expected = <<<EXPECTED
551 Hello!
553 I'm writing to you from the Moodle Majlis in Muscat, Oman, where we just had several days of Moodle community goodness.
555 URL outside a tag: https://moodle.org/logo/logo-240x60.gif
556 Plugin url outside a tag: @@PLUGINFILE@@/logo-240x60.gif
558 External link 1:<img src="https://moodle.org/logo/logo-240x60.gif" alt="Moodle" />
559 External link 2:<img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif" />
560 Internal link 1:
561 Internal link 2:
562 Anchor link 1:Link text
563 Anchor link 2:<a title="bananas" href="../logo-240x60.gif">Link text</a>
564 Anchor + ext. img:<a title="bananas" href="../logo-240x60.gif"></a>
565 Ext. anchor + img:<img alt="Moodle" src="https://moodle.org/logo/logo-240x60.gif" />
566 EXPECTED;
567 $this->assertSame($expected, strip_pluginfile_content($source));