mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding native-type-generation fixes for JavascriptHelper::object()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8095 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2009f4b896
commit
36d3540c19
2 changed files with 13 additions and 1 deletions
|
@ -525,6 +525,13 @@ class JavascriptHelper extends AppHelper {
|
|||
if ($this->useNative) {
|
||||
$rt = json_encode($data);
|
||||
} else {
|
||||
if (is_null($data)) {
|
||||
return 'null';
|
||||
}
|
||||
if (is_bool($data)) {
|
||||
return $data ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if (is_array($data)) {
|
||||
$keys = array_keys($data);
|
||||
}
|
||||
|
|
|
@ -366,13 +366,18 @@ class JavascriptTest extends CakeTestCase {
|
|||
$expected = '{"title":"New thing","indexes":[5,6,7,8],"object":{"inner":{"value":1}}}';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
foreach (array('true' => true, 'false' => false, 'null' => null) as $expected => $data) {
|
||||
$result = $this->Javascript->object($data);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
if ($this->Javascript->useNative) {
|
||||
$this->Javascript->useNative = false;
|
||||
$this->testObjectGeneration();
|
||||
$this->Javascript->useNative = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* testObjectNonNative method
|
||||
*
|
||||
* @access public
|
||||
|
|
Loading…
Reference in a new issue