mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +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
fc499ac48f
commit
ab688b88f4
2 changed files with 11 additions and 1 deletions
|
@ -632,7 +632,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']) ||
|
||||
|
|
|
@ -392,6 +392,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…
Add table
Reference in a new issue