Added missing test + minor cleanup of ViewTests.php

Added missing block reset test through assign().
Also made some minor cleanup in ViewTests.php. Mostly docblocks (params, returns) but also some unused variables.
This commit is contained in:
Marc Würth 2013-07-20 01:06:27 +02:00
parent 481d3920ae
commit da8e50a48a

View file

@ -106,7 +106,7 @@ class TestThemeView extends View {
* *
* @param string $name * @param string $name
* @param array $params * @param array $params
* @return void * @return string The given name
*/ */
public function renderElement($name, $params = array()) { public function renderElement($name, $params = array()) {
return $name; return $name;
@ -115,8 +115,8 @@ class TestThemeView extends View {
/** /**
* getViewFileName method * getViewFileName method
* *
* @param string $name * @param string $name Controller action to find template filename for
* @return void * @return string Template filename
*/ */
public function getViewFileName($name = null) { public function getViewFileName($name = null) {
return $this->_getViewFileName($name); return $this->_getViewFileName($name);
@ -125,8 +125,8 @@ class TestThemeView extends View {
/** /**
* getLayoutFileName method * getLayoutFileName method
* *
* @param string $name * @param string $name The name of the layout to find.
* @return void * @return string Filename for layout file (.ctp).
*/ */
public function getLayoutFileName($name = null) { public function getLayoutFileName($name = null) {
return $this->_getLayoutFileName($name); return $this->_getLayoutFileName($name);
@ -144,8 +144,8 @@ class TestView extends View {
/** /**
* getViewFileName method * getViewFileName method
* *
* @param string $name * @param string $name Controller action to find template filename for
* @return void * @return string Template filename
*/ */
public function getViewFileName($name = null) { public function getViewFileName($name = null) {
return $this->_getViewFileName($name); return $this->_getViewFileName($name);
@ -154,8 +154,8 @@ class TestView extends View {
/** /**
* getLayoutFileName method * getLayoutFileName method
* *
* @param string $name * @param string $name The name of the layout to find.
* @return void * @return string Filename for layout file (.ctp).
*/ */
public function getLayoutFileName($name = null) { public function getLayoutFileName($name = null) {
return $this->_getLayoutFileName($name); return $this->_getLayoutFileName($name);
@ -164,9 +164,9 @@ class TestView extends View {
/** /**
* paths method * paths method
* *
* @param string $plugin * @param string $plugin Optional plugin name to scan for view files.
* @param boolean $cached * @param boolean $cached Set to true to force a refresh of view paths.
* @return void * @return array paths
*/ */
public function paths($plugin = null, $cached = true) { public function paths($plugin = null, $cached = true) {
return $this->_paths($plugin, $cached); return $this->_paths($plugin, $cached);
@ -200,6 +200,7 @@ class TestAfterHelper extends Helper {
/** /**
* beforeLayout method * beforeLayout method
* *
* @param string $viewFile
* @return void * @return void
*/ */
public function beforeLayout($viewFile) { public function beforeLayout($viewFile) {
@ -209,6 +210,7 @@ class TestAfterHelper extends Helper {
/** /**
* afterLayout method * afterLayout method
* *
* @param string $layoutFile
* @return void * @return void
*/ */
public function afterLayout($layoutFile) { public function afterLayout($layoutFile) {
@ -529,7 +531,7 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller); $View = new TestView($this->Controller);
ob_start(); ob_start();
$result = $View->getViewFileName('does_not_exist'); $View->getViewFileName('does_not_exist');
$this->ThemeController->plugin = null; $this->ThemeController->plugin = null;
$this->ThemeController->name = 'Pages'; $this->ThemeController->name = 'Pages';
@ -557,8 +559,8 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller); $View = new TestView($this->Controller);
ob_start(); ob_start();
$result = $View->getLayoutFileName(); $View->getLayoutFileName();
$expected = ob_get_clean(); ob_get_clean();
$this->ThemeController->plugin = null; $this->ThemeController->plugin = null;
$this->ThemeController->name = 'Posts'; $this->ThemeController->name = 'Posts';
@ -567,7 +569,7 @@ class ViewTest extends CakeTestCase {
$this->ThemeController->theme = 'my_theme'; $this->ThemeController->theme = 'my_theme';
$View = new TestThemeView($this->ThemeController); $View = new TestThemeView($this->ThemeController);
$result = $View->getLayoutFileName(); $View->getLayoutFileName();
} }
/** /**
@ -762,7 +764,7 @@ class ViewTest extends CakeTestCase {
$result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view'); $result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $View->element('test_element', array( $View->element('test_element', array(
'param' => 'one', 'param' => 'one',
'foo' => 'two' 'foo' => 'two'
), array( ), array(
@ -772,7 +774,7 @@ class ViewTest extends CakeTestCase {
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$View->elementCache = 'default'; $View->elementCache = 'default';
$result = $View->element('test_element', array( $View->element('test_element', array(
'param' => 'one', 'param' => 'one',
'foo' => 'two' 'foo' => 'two'
), array( ), array(
@ -1310,6 +1312,17 @@ class ViewTest extends CakeTestCase {
$this->assertEquals('Block content', $result); $this->assertEquals('Block content', $result);
} }
/**
* Test resetting a block's content.
*
* @return void
*/
public function testBlockReset() {
$this->View->assign('test', '');
$result = $this->View->fetch('test', 'This should not be returned');
$this->assertSame('', $result);
}
/** /**
* Test appending to a block with append. * Test appending to a block with append.
* *