mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix errors when testing controllers that use file()
Fix errors related to ob_end_clean() closing PHPUnit's output buffer when testing controller methods that use response->file().
This commit is contained in:
parent
a6aefdd4d3
commit
5f2aa4c307
3 changed files with 17 additions and 1 deletions
|
@ -300,6 +300,18 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$this->assertSame(302, $Controller->response->statusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that file responses don't trigger errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActionWithFile() {
|
||||
$Controller = $this->Case->generate('TestsApps');
|
||||
$this->Case->testAction('/tests_apps/file');
|
||||
$this->assertArrayHasKey('Content-Disposition', $Controller->response->header());
|
||||
$this->assertArrayHasKey('Content-Length', $Controller->response->header());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure testAction() can hit plugin controllers.
|
||||
*
|
||||
|
|
|
@ -44,6 +44,10 @@ class TestsAppsController extends AppController {
|
|||
$this->render('index');
|
||||
}
|
||||
|
||||
public function file() {
|
||||
$this->response->file(__FILE__);
|
||||
}
|
||||
|
||||
public function redirect_to() {
|
||||
return $this->redirect('http://cakephp.org');
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
$params['requested'] = 1;
|
||||
}
|
||||
$Dispatch->testController = $this->controller;
|
||||
$Dispatch->response = $this->getMock('CakeResponse', array('send'));
|
||||
$Dispatch->response = $this->getMock('CakeResponse', array('send', '_clearBuffer'));
|
||||
$this->result = $Dispatch->dispatch($request, $Dispatch->response, $params);
|
||||
$this->controller = $Dispatch->testController;
|
||||
$this->vars = $this->controller->viewVars;
|
||||
|
|
Loading…
Reference in a new issue