mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Appending .js to strings like script-x.x.x in link() function
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4615 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c07021b2bc
commit
8917efcc0a
2 changed files with 19 additions and 1 deletions
|
@ -129,7 +129,7 @@ class JavascriptHelper extends AppHelper {
|
|||
return;
|
||||
}
|
||||
|
||||
if (strpos($url, '.') === false && strpos($url, '?') === false) {
|
||||
if (strpos($url, '.js') === false && strpos($url, '?') === false) {
|
||||
$url .= '.js';
|
||||
}
|
||||
if (strpos($url, '://') === false) {
|
||||
|
|
|
@ -46,6 +46,24 @@ class JavascriptTest extends UnitTestCase {
|
|||
$this->js->Form = new FormHelper();
|
||||
}
|
||||
|
||||
function testLink() {
|
||||
$result = $this->js->link('script.js');
|
||||
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
||||
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->js->link('script');
|
||||
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
||||
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->js->link('scriptaculous.js?load=effects');
|
||||
$expected = '<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>';
|
||||
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->js->link('jquery-1.1.2');
|
||||
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
|
||||
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
||||
}
|
||||
|
||||
function testObjectGeneration() {
|
||||
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue