mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing return value for JavascriptHelper::blockEnd() for script caching (Ticket #3172)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5686 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
52f1e2dc5c
commit
8f4dd39257
2 changed files with 31 additions and 5 deletions
|
@ -105,8 +105,8 @@ class JavascriptHelper extends AppHelper {
|
|||
|
||||
if (!empty($script)) {
|
||||
$this->_cachedEvents[] = $script;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->tags['javascriptend'];
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -75,17 +75,43 @@ class JavascriptTest extends UnitTestCase {
|
|||
|
||||
$result = $this->Javascript->object(array(
|
||||
'2007' => array(
|
||||
'Spring'=>array('1'=>array('id'=>'1','name'=>'Josh'), '2'=>array('id'=>'2','name'=>'Becky')),
|
||||
'Fall' => array('1'=>array('id'=>'1','name'=>'Josh'), '2'=>array('id'=>'2','name'=>'Becky'))
|
||||
'Spring' => array('1' => array('id' => '1', 'name' => 'Josh'), '2' => array('id' => '2', 'name' => 'Becky')),
|
||||
'Fall' => array('1' => array('id' => '1', 'name' => 'Josh'), '2' => array('id' => '2', 'name' => 'Becky'))
|
||||
), '2006' => array(
|
||||
'Spring' => array('1'=>array('id'=>'1','name'=>'Josh'), '2'=>array('id'=>'2','name'=>'Becky')),
|
||||
'Fall' => array('1' => array('id'=>'1','name'=>'Josh'), '2'=>array('id'=>'2','name'=>'Becky')
|
||||
'Spring' => array('1' => array('id' => '1', 'name' => 'Josh'), '2' => array('id' => '2', 'name' => 'Becky')),
|
||||
'Fall' => array('1' => array('id' => '1', 'name' => 'Josh'), '2' => array('id' => '2', 'name' => 'Becky')
|
||||
))
|
||||
));
|
||||
$expected = '{"2007":{"Spring":{"1":{"id":1, "name":"Josh"}, "2":{"id":2, "name":"Becky"}}, "Fall":{"1":{"id":1, "name":"Josh"}, "2":{"id":2, "name":"Becky"}}}, "2006":{"Spring":{"1":{"id":1, "name":"Josh"}, "2":{"id":2, "name":"Becky"}}, "Fall":{"1":{"id":1, "name":"Josh"}, "2":{"id":2, "name":"Becky"}}}}';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testScriptBlock() {
|
||||
$result = $this->Javascript->codeBlock("something");
|
||||
$this->assertPattern('/^<script[^<>]+>something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
|
||||
$result = $this->Javascript->codeBlock();
|
||||
$this->assertPattern('/^<script[^<>]+>$/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
|
||||
$result = $this->Javascript->blockEnd();
|
||||
$this->assertEqual("</script>", $result);
|
||||
|
||||
$this->Javascript->cacheEvents(false, true);
|
||||
$result = $this->Javascript->codeBlock();
|
||||
$this->assertIdentical($result, null);
|
||||
echo 'alert("this is a buffered script");';
|
||||
|
||||
$result = $this->Javascript->blockEnd();
|
||||
$this->assertIdentical($result, null);
|
||||
|
||||
$result = $this->Javascript->getCache();
|
||||
$this->assertEqual('alert("this is a buffered script");', $result);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->Javascript);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue