Skip to content
Permalink
Browse files

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.
  • Loading branch information...
ravage84 committed Jul 19, 2013
1 parent 481d392 commit da8e50a48a162cbdb840087394afdd2bb3843b21
Showing with 31 additions and 18 deletions.
  1. +31 −18 lib/Cake/Test/Case/View/ViewTest.php
@@ -106,7 +106,7 @@ class TestThemeView extends View {
*
* @param string $name
* @param array $params
* @return void
* @return string The given name
*/
public function renderElement($name, $params = array()) {
return $name;
@@ -115,8 +115,8 @@ public function renderElement($name, $params = array()) {
/**
* getViewFileName method
*
* @param string $name
* @return void
* @param string $name Controller action to find template filename for
* @return string Template filename
*/
public function getViewFileName($name = null) {
return $this->_getViewFileName($name);
@@ -125,8 +125,8 @@ public function getViewFileName($name = null) {
/**
* getLayoutFileName method
*
* @param string $name
* @return void
* @param string $name The name of the layout to find.
* @return string Filename for layout file (.ctp).
*/
public function getLayoutFileName($name = null) {
return $this->_getLayoutFileName($name);
@@ -144,8 +144,8 @@ class TestView extends View {
/**
* getViewFileName method
*
* @param string $name
* @return void
* @param string $name Controller action to find template filename for
* @return string Template filename
*/
public function getViewFileName($name = null) {
return $this->_getViewFileName($name);
@@ -154,8 +154,8 @@ public function getViewFileName($name = null) {
/**
* getLayoutFileName method
*
* @param string $name
* @return void
* @param string $name The name of the layout to find.
* @return string Filename for layout file (.ctp).
*/
public function getLayoutFileName($name = null) {
return $this->_getLayoutFileName($name);
@@ -164,9 +164,9 @@ public function getLayoutFileName($name = null) {
/**
* paths method
*
* @param string $plugin
* @param boolean $cached
* @return void
* @param string $plugin Optional plugin name to scan for view files.
* @param boolean $cached Set to true to force a refresh of view paths.
* @return array paths
*/
public function paths($plugin = null, $cached = true) {
return $this->_paths($plugin, $cached);
@@ -200,6 +200,7 @@ class TestAfterHelper extends Helper {
/**
* beforeLayout method
*
* @param string $viewFile
* @return void
*/
public function beforeLayout($viewFile) {
@@ -209,6 +210,7 @@ public function beforeLayout($viewFile) {
/**
* afterLayout method
*
* @param string $layoutFile
* @return void
*/
public function afterLayout($layoutFile) {
@@ -529,7 +531,7 @@ public function testMissingView() {
$View = new TestView($this->Controller);
ob_start();
$result = $View->getViewFileName('does_not_exist');
$View->getViewFileName('does_not_exist');
$this->ThemeController->plugin = null;
$this->ThemeController->name = 'Pages';
@@ -557,8 +559,8 @@ public function testMissingLayout() {
$View = new TestView($this->Controller);
ob_start();
$result = $View->getLayoutFileName();
$expected = ob_get_clean();
$View->getLayoutFileName();
ob_get_clean();
$this->ThemeController->plugin = null;
$this->ThemeController->name = 'Posts';
@@ -567,7 +569,7 @@ public function testMissingLayout() {
$this->ThemeController->theme = 'my_theme';
$View = new TestThemeView($this->ThemeController);
$result = $View->getLayoutFileName();
$View->getLayoutFileName();
}
/**
@@ -762,7 +764,7 @@ public function testElementCache() {
$result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view');
$this->assertEquals($expected, $result);
$result = $View->element('test_element', array(
$View->element('test_element', array(
'param' => 'one',
'foo' => 'two'
), array(
@@ -772,7 +774,7 @@ public function testElementCache() {
$this->assertEquals($expected, $result);
$View->elementCache = 'default';
$result = $View->element('test_element', array(
$View->element('test_element', array(
'param' => 'one',
'foo' => 'two'
), array(
@@ -1310,6 +1312,17 @@ public function testBlockSet() {
$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.
*

0 comments on commit da8e50a

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