Permalink
Browse files

Backport helper method for view blocks from 3.0

Related PR is #5385
  • Loading branch information...
Walther Lalk
Walther Lalk committed Dec 11, 2014
1 parent c32e165 commit 9be725613e818ed9cc1b8775dbbe569397904f70
Showing with 31 additions and 0 deletions.
  1. +11 −0 lib/Cake/Test/Case/View/ViewTest.php
  2. +10 −0 lib/Cake/View/View.php
  3. +10 −0 lib/Cake/View/ViewBlock.php
@@ -1425,6 +1425,17 @@ public function testBlockReset() {
$this->assertSame('', $result);
}
/**
* Test checking a block's existance.
*
* @return void
*/
public function testBlockExist() {
$this->assertFalse($this->View->exists('test'));
$this->View->assign('test', 'Block content');
$this->assertTrue($this->View->exists('test'));
}
/**
* Test setting a block's content to null
*
View
@@ -698,6 +698,16 @@ public function fetch($name, $default = '') {
return $this->Blocks->get($name, $default);
}
/**
* Check if a block exists
*
* @param string $name Name of the block
* @return bool
*/
public function exists($name) {
return $this->Blocks->exists($name);
}
/**
* End a capturing block. The compliment to View::start()
*
@@ -196,6 +196,16 @@ public function get($name, $default = '') {
return $this->_blocks[$name];
}
/**
* Check if a block exists
*
* @param string $name Name of the block
* @return bool
*/
public function exists($name) {
return isset($this->_blocks[$name]);
}
/**
* Get the names of all the existing blocks.
*

0 comments on commit 9be7256

Please sign in to comment.