Skip to content
Permalink
Browse files

Fix risky tests.

Failing to close output buffers makes PHPUnit unhappy. Switch to test
styles that allow all created buffers to be closed.
  • Loading branch information...
markstory committed Sep 28, 2014
1 parent 7ad3186 commit 92bd86274b64c31ef6034caa74bb168be041b5e0
@@ -224,6 +224,7 @@ public function testAsset($url, $file) {
$request = new Request($url);
$event = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response'));
ob_start();
$filter->beforeDispatch($event);
$result = ob_get_contents();
ob_end_clean();
@@ -1475,23 +1475,33 @@ public function testNestedBlocks() {
/**
* Test that starting the same block twice throws an exception
*
* @expectedException \Cake\Core\Exception\Exception
* @return void
*/
public function testStartBlocksTwice() {
$this->View->start('first');
$this->View->start('first');
try {
$this->View->start('first');
$this->View->start('first');
$this->fail('No exception');
} catch (\Cake\Core\Exception\Exception $e) {
ob_end_clean();
$this->assertTrue(true);
}
}
/**
* Test that an exception gets thrown when you leave a block open at the end
* of a view.
*
* @expectedException \LogicException
* @return void
*/
public function testExceptionOnOpenBlock() {
$this->View->render('open_block');
try {
$this->View->render('open_block');
$this->fail('No exception');
} catch (\LogicException $e) {
ob_end_clean();
$this->assertContains('The "no_close" block was left open', $e->getMessage());
}
}
/**
@@ -1514,23 +1524,32 @@ public function testExtendNested() {
/**
* Make sure that extending the current view with itself causes an exception
*
* @expectedException LogicException
* @return void
*/
public function testExtendSelf() {
$this->View->layout = false;
$this->View->render('extend_self');
try {
$this->View->layout = false;
$this->View->render('extend_self');
$this->fail('No exception');
} catch (\LogicException $e) {
ob_end_clean();
$this->assertContains('cannot have views extend themselves', $e->getMessage());
}
}
/**
* Make sure that extending in a loop causes an exception
*
* @expectedException LogicException
* @return void
*/
public function testExtendLoop() {
$this->View->layout = false;
$this->View->render('extend_loop');
try {
$this->View->layout = false;
$this->View->render('extend_loop');
} catch (\LogicException $e) {
ob_end_clean();
$this->assertContains('cannot have views extend in a loop', $e->getMessage());
}
}
/**
@@ -1554,12 +1573,18 @@ public function testExtendElement() {
/**
* Extending an element which doesn't exist should throw a missing view exception
*
* @expectedException LogicException
* @return void
*/
public function testExtendMissingElement() {
$this->View->layout = false;
$this->View->render('extend_missing_element');
try {
$this->View->layout = false;
$this->View->render('extend_missing_element');
$this->fail('No exception');
} catch (\LogicException $e) {
ob_end_clean();
ob_end_clean();
$this->assertContains('element', $e->getMessage());
}
}
/**
@@ -0,0 +1 @@
/* company.css */

0 comments on commit 92bd862

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