mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing HtmlHelper::css, and JavascriptHelper::link so that files containing the asset extension always get the extension added. Test cases added. Refs #139
This commit is contained in:
parent
f12cbdba38
commit
c47e899ba1
4 changed files with 10 additions and 2 deletions
|
@ -344,7 +344,7 @@ class HtmlHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($path, '?') === false) {
|
if (strpos($path, '?') === false) {
|
||||||
if (strpos($path, '.css') === false) {
|
if (substr($path, -4) !== '.css') {
|
||||||
$path .= '.css';
|
$path .= '.css';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ class JavascriptHelper extends AppHelper {
|
||||||
$url = JS_URL . $url;
|
$url = JS_URL . $url;
|
||||||
}
|
}
|
||||||
if (strpos($url, '?') === false) {
|
if (strpos($url, '?') === false) {
|
||||||
if (strpos($url, '.js') === false) {
|
if (substr($url, -3) !== '.js') {
|
||||||
$url .= '.js';
|
$url .= '.js';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,6 +362,10 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
$result = $this->Html->css('screen.css');
|
$result = $this->Html->css('screen.css');
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Html->css('my.css.library');
|
||||||
|
$expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/';
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Html->css('screen.css?1234');
|
$result = $this->Html->css('screen.css?1234');
|
||||||
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
|
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
|
@ -166,6 +166,10 @@ class JavascriptTest extends CakeTestCase {
|
||||||
$expected = '<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>';
|
$expected = '<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Javascript->link('some.json.libary');
|
||||||
|
$expected = '<script type="text/javascript" src="js/some.json.libary.js"></script>';
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Javascript->link('jquery-1.1.2');
|
$result = $this->Javascript->link('jquery-1.1.2');
|
||||||
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
|
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
Loading…
Reference in a new issue