mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +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'];
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -86,6 +86,32 @@ class JavascriptTest extends UnitTestCase {
|
|||
$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