Skip to content

Commit

Permalink
More testing over the MediaView class
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Oct 4, 2010
1 parent 9daab17 commit 5c025d0
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions cake/tests/cases/libs/view/media.test.php
Expand Up @@ -59,7 +59,7 @@ function tearDown() {
/**
* tests that rendering a file that does not exists throws an exception
*
* @expectedException NotFoundException
* @expectedException NotFoundException
* @return void
*/
public function testRenderNotFound() {
Expand All @@ -80,7 +80,7 @@ function testRender() {
$this->MediaView->viewVars = array(
'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
'extension' => 'css',
);
$this->MediaView->expects($this->exactly(2))
->method('_isActive')
Expand Down Expand Up @@ -123,7 +123,55 @@ function testRender() {
* @return void
*/
function testConnectionAborted() {
$this->MediaView->active = false;
$this->MediaView->viewVars = array(
'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);

$this->MediaView->expects($this->once())
->method('_isActive')
->will($this->returnValue(false));

$this->MediaView->response->expects($this->once())
->method('type')
->with('css')
->will($this->returnArgument(0));

$result = $this->MediaView->render();
$this->assertFalse($result);
}

/**
* testConnectionAbortedOnBuffering method
*
* @access public
* @return void
*/
function testConnectionAbortedOnBuffering() {
$this->MediaView->viewVars = array(
'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);

$this->MediaView->expects($this->at(0))
->method('_isActive')
->will($this->returnValue(true));

$this->MediaView->response->expects($this->any())
->method('type')
->with('css')
->will($this->returnArgument(0));

$this->MediaView->expects($this->at(1))
->method('_isActive')
->will($this->returnValue(false));

$this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->expects($this->once())->method('_clearBuffer');
$this->MediaView->expects($this->never())->method('_flushBuffer');

$result = $this->MediaView->render();
$this->assertFalse($result);
}
Expand Down

0 comments on commit 5c025d0

Please sign in to comment.