Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding test to check that postfix and prefix options don't go into in…

…ner objects. Tests added, fixes #348
  • Loading branch information...
commit 2209f198f88197e0600d5c0ca375e78e572c2e11 1 parent e09e520
@markstory markstory authored
View
5 cake/libs/view/helpers/javascript.php
@@ -639,7 +639,10 @@ function object($data = array(), $options = array()) {
foreach ($data as $key => $val) {
if (is_array($val) || is_object($val)) {
- $val = $this->object($val, array_merge($options, array('block' => false)));
+ $val = $this->object(
+ $val,
+ array_merge($options, array('block' => false, 'prefix' => '', 'postfix' => ''))
+ );
} else {
$quoteStrings = (
!count($options['stringKeys']) ||
View
7 cake/tests/cases/libs/view/helpers/javascript.test.php
@@ -404,6 +404,13 @@ function testObjectGeneration() {
$result = $this->Javascript->object($data);
$this->assertEqual($result, $expected);
}
+
+ $object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1)));
+ $result = $this->Javascript->object($object, array('prefix' => 'PREFIX', 'postfix' => 'POSTFIX'));
+ $this->assertPattern('/^PREFIX/', $result);
+ $this->assertPattern('/POSTFIX$/', $result);
+ $this->assertNoPattern('/.PREFIX./', $result);
+ $this->assertNoPattern('/.POSTFIX./', $result);
if ($this->Javascript->useNative) {
$this->Javascript->useNative = false;
Please sign in to comment.
Something went wrong with that request. Please try again.