mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding test to check that postfix and prefix options don't go into inner objects. Tests added, fixes #348
This commit is contained in:
parent
e09e520fd5
commit
2209f198f8
2 changed files with 11 additions and 1 deletions
|
@ -639,7 +639,10 @@ class JavascriptHelper extends AppHelper {
|
|||
|
||||
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']) ||
|
||||
|
|
|
@ -404,6 +404,13 @@ class JavascriptTest extends CakeTestCase {
|
|||
$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;
|
||||
|
|
Loading…
Reference in a new issue