mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding JavascriptHelper::object() fix for 0 being converted to null (Ticket #2296)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4680 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
bb2a68caec
commit
8e92df3bbb
2 changed files with 10 additions and 6 deletions
|
@ -373,7 +373,7 @@ class JavascriptHelper extends AppHelper {
|
||||||
if ((!count($stringKeys) && !is_numeric($val) && !is_bool($val)) || ($quoteKeys && in_array($key, $stringKeys, true)) || (!$quoteKeys && !in_array($key, $stringKeys, true))) {
|
if ((!count($stringKeys) && !is_numeric($val) && !is_bool($val)) || ($quoteKeys && in_array($key, $stringKeys, true)) || (!$quoteKeys && !in_array($key, $stringKeys, true))) {
|
||||||
$val = $q . $this->escapeString($val) . $q;
|
$val = $q . $this->escapeString($val) . $q;
|
||||||
}
|
}
|
||||||
if ($val == null) {
|
if ($val === null) {
|
||||||
$val = 'null';
|
$val = 'null';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,19 +49,19 @@ class JavascriptTest extends UnitTestCase {
|
||||||
function testLink() {
|
function testLink() {
|
||||||
$result = $this->js->link('script.js');
|
$result = $this->js->link('script.js');
|
||||||
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
||||||
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->js->link('script');
|
$result = $this->js->link('script');
|
||||||
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
||||||
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->js->link('scriptaculous.js?load=effects');
|
$result = $this->js->link('scriptaculous.js?load=effects');
|
||||||
$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, "Error creating link, expected '{$expected}', got '{$result}'.");
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->js->link('jquery-1.1.2');
|
$result = $this->js->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, "Error creating link, expected '{$expected}', got '{$result}'.");
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testObjectGeneration() {
|
function testObjectGeneration() {
|
||||||
|
@ -69,7 +69,11 @@ class JavascriptTest extends UnitTestCase {
|
||||||
|
|
||||||
$result = $this->js->object($object);
|
$result = $this->js->object($object);
|
||||||
$expected = '{"title":"New thing", "indexes":[5, 6, 7, 8]}';
|
$expected = '{"title":"New thing", "indexes":[5, 6, 7, 8]}';
|
||||||
$this->assertEqual($result, $expected, "Error generating JavaScript object, expected '{$expected}', got '{$result}'.");
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->js->object(array('default' => 0));
|
||||||
|
$expected = '{"default":0}';
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue