Skip to content
Permalink
Browse files

Patch for issue #7561

Add reset method and tests
  • Loading branch information...
jeffblack360 committed Dec 8, 2015
1 parent 492cb4b commit 2714e1459ec08ff07e775c7f3e31ed7159df7a13
Showing with 29 additions and 0 deletions.
  1. +13 −0 src/View/View.php
  2. +16 −0 tests/TestCase/View/ViewTest.php
@@ -737,6 +737,19 @@ public function assign($name, $value)
$this->Blocks->set($name, $value);
}
/**
* Reset the content for a block. This will overwrite any
* existing content.
*
* @param string $name Name of the block
* @return void
* @see ViewBlock::set()
*/
public function reset($name)
{
$this->assign($name, '');
}
/**
* Fetch the content for a block. If a block is
* empty or undefined '' will be returned.
@@ -1488,6 +1488,22 @@ public function testBlockReset()
$this->assertSame('', $result);
}
/**
* Test resetting a block's content with reset.
*
* @return void
*/
public function testBlockResetFunc()
{
$this->View->assign('test', 'Block content');
$result = $this->View->fetch('test', 'This should not be returned');
$this->assertSame('Block content', $result);
$this->View->reset('test');
$result = $this->View->fetch('test', 'This should not be returned');
$this->assertSame('', $result);
}
/**
* Test checking a block's existance.
*

0 comments on commit 2714e14

Please sign in to comment.
You can’t perform that action at this time.