mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Fixing failing tests for Controller.
Adding a string cast for easier testing.
This commit is contained in:
parent
b0749acbb6
commit
70744f3cb4
3 changed files with 19 additions and 10 deletions
|
@ -790,7 +790,7 @@ class Controller extends Object {
|
|||
*
|
||||
* @param string $view View to use for rendering
|
||||
* @param string $layout Layout to use
|
||||
* @return string Full output string of view contents
|
||||
* @return CakeResponse A response object containing the rendered view.
|
||||
* @link http://book.cakephp.org/view/980/render
|
||||
*/
|
||||
public function render($view = null, $layout = null) {
|
||||
|
@ -880,7 +880,7 @@ class Controller extends Object {
|
|||
$this->set('message', $message);
|
||||
$this->set('pause', $pause);
|
||||
$this->set('page_title', $message);
|
||||
$this->response->body($this->render(false, $layout));
|
||||
$this->render(false, $layout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -300,7 +300,7 @@ class CakeResponse {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_body = null;
|
||||
protected $_body = '';
|
||||
|
||||
/**
|
||||
* The charset the response body is encoded with
|
||||
|
@ -654,4 +654,14 @@ class CakeResponse {
|
|||
public function download($filename) {
|
||||
$this->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* String conversion. Fetches the response body as a string.
|
||||
* Does *not* send headers.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->_body;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -525,8 +525,7 @@ class ControllerTest extends CakeTestCase {
|
|||
$request->webroot = '/';
|
||||
$request->base = '/';
|
||||
|
||||
$Controller = new Controller($request);
|
||||
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$Controller = new Controller($request, $this->getMock('CakeResponse', array('_sendHeader')));
|
||||
$Controller->flash('this should work', '/flash');
|
||||
$result = $Controller->response->body();
|
||||
|
||||
|
@ -622,14 +621,14 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->viewPath = 'Posts';
|
||||
|
||||
$result = $Controller->render('index');
|
||||
$this->assertPattern('/posts index/', $result);
|
||||
$this->assertPattern('/posts index/', (string)$result);
|
||||
|
||||
$Controller->view = 'index';
|
||||
$result = $Controller->render();
|
||||
$this->assertPattern('/posts index/', $result);
|
||||
$this->assertPattern('/posts index/', (string)$result);
|
||||
|
||||
$result = $Controller->render('/Elements/test_element');
|
||||
$this->assertPattern('/this is the test element/', $result);
|
||||
$this->assertPattern('/this is the test element/', (string)$result);
|
||||
$Controller->view = null;
|
||||
|
||||
$Controller = new TestController($request, new CakeResponse());
|
||||
|
@ -677,7 +676,7 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->viewPath = 'Posts';
|
||||
$Controller->theme = 'TestTheme';
|
||||
$result = $Controller->render('index');
|
||||
$this->assertPattern('/default test_theme layout/', $result);
|
||||
$this->assertPattern('/default test_theme layout/', (string)$result);
|
||||
App::build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue