function CDNImageTestCase::testOtherContentLink in CDN 7.2
File
- tests/cdn.test, line 582
- Test CDN.
Class
- CDNImageTestCase
Code
function testOtherContentLink() {
$cdn = 'http://cdn-a.com';
$this
->variableSet(CDN_BASIC_MAPPING_VARIABLE, "{$cdn}|.png .pdf");
$this
->variableSet(CDN_MODE_VARIABLE, CDN_MODE_BASIC);
$template = function ($url) {
return '<a href="' . $url . '">Download this!</a>';
};
$a_url = base_path() . 'foo/bar/image.png';
$html = $template($a_url);
$html = cdn_post_render_html_alter($html);
$this
->assertIdentical($template($cdn . $a_url), $html, 'Other content link correctly altered.');
$a_url = base_path() . 'foo/bar/image.pdf?foobar';
$html = $template($a_url);
$html = cdn_post_render_html_alter($html);
$this
->assertIdentical($template($cdn . $a_url), $html, 'Other content link correctly altered (query string not stripped).');
$a_url = base_path() . 'foo/bar/image.gif';
$html = $template($a_url);
$html = cdn_post_render_html_alter($html);
$this
->assertIdentical($template($a_url), $html, 'Other content link correctly NOT altered (extension does not map).');
$a_url = base_path() . 'foo/bar/showimage?formula=12345.png';
$html = $template($a_url);
$html = cdn_post_render_html_alter($html);
$this
->assertIdentical($template($a_url), $html, 'Other content link correctly NOT altered (extension not pulled from query string).');
}