Browse Source

Merge pull request #3688 from markstory/3.0-view-append-capture

Re-instate the capture mode of View::append().
José Lorenzo Rodríguez 11 years ago
parent
commit
efdb1eabb4
2 changed files with 13 additions and 11 deletions
  1. 7 2
      src/View/View.php
  2. 6 9
      tests/TestCase/View/ViewTest.php

+ 7 - 2
src/View/View.php

@@ -622,8 +622,13 @@ class View {
  * @return void
  * @see ViewBlock::concat()
  */
-	public function append($name, $value) {
-		$this->Blocks->concat($name, $value);
+	public function append($name, $value = null) {
+		if ($value !== null) {
+			$this->Blocks->concat($name, $value);
+			return;
+		}
+		$this->Blocks->start($name);
+		echo $this->Blocks->get($name);
 	}
 
 /**

+ 6 - 9
tests/TestCase/View/ViewTest.php

@@ -554,9 +554,7 @@ class ViewTest extends TestCase {
 		$response = $this->getMock('Cake\Network\Response');
 
 		$View = new TestView($request, $response, null, $viewOptions);
-		ob_start();
 		$View->getViewFileName('does_not_exist');
-		ob_get_clean();
 	}
 
 /**
@@ -572,9 +570,7 @@ class ViewTest extends TestCase {
 			'layout' => 'whatever'
 		];
 		$View = new TestView(null, null, null, $viewOptions);
-		ob_start();
 		$View->getLayoutFileName();
-		ob_get_clean();
 	}
 
 /**
@@ -1185,15 +1181,17 @@ class ViewTest extends TestCase {
  *
  * @return void
  */
-	public function testBlockCaptureAppend() {
+	public function testBlockAppendCapture() {
 		$this->View->start('test');
-		echo 'Block';
+		echo 'Content ';
 		$this->View->end();
 
-		$this->View->append('test', ' content');
+		$this->View->append('test');
+		echo 'appended';
+		$this->View->end();
 
 		$result = $this->View->fetch('test');
-		$this->assertEquals('Block content', $result);
+		$this->assertEquals('Content appended', $result);
 	}
 
 /**
@@ -1275,7 +1273,6 @@ class ViewTest extends TestCase {
 	public static function blockValueProvider() {
 		return array(
 			'string' => array('A string value'),
-			'null' => array(null),
 			'decimal' => array(1.23456),
 			'object with __toString' => array(new TestObjectWithToString()),
 		);