Skip to content
Browse files

Going green after #536 where test cases were added to test exception …

…handling in test cases.
  • Loading branch information...
1 parent 7e42ea7 commit d4ae2a62d25e81ef3eb73ca0f82ef08e47c0da0d @gwoo gwoo committed Jul 5, 2012
Showing with 16 additions and 5 deletions.
  1. +6 −2 test/Unit.php
  2. +8 −1 tests/cases/test/GroupTest.php
  3. +2 −2 tests/cases/test/UnitTest.php
View
8 test/Unit.php
@@ -744,8 +744,12 @@ protected function _runTestMethod($method, $options) {
));
}
$this->_expected = array();
- $this->tearDown();
+ try {
+ $this->tearDown();
+ } catch (Exception $e) {
+ $this->_handleException($e, __LINE__ - 2);
+ }
return $passed;
}
@@ -1017,7 +1021,7 @@ protected function _arrayPermute($items, $perms = array()) {
* If the file to unlink is readonly, it throws a exception (Permission denied) on Windows.
* So, the file is checked before an unlink is tried. (this will make the tests run slower
* but is prefered over a if (!unlink { chmod; unlink }.
- * See: http://stringoftheseus.com/blog/2010/12/22/php-unlink-permisssion-denied-error-on-windows/
+ * http://stringoftheseus.com/blog/2010/12/22/php-unlink-permisssion-denied-error-on-windows/
*
* @param string $path Path to directory with contents to remove. If first
* character is NOT a slash (`/`) or a Windows drive letter (`C:`)
View
9 tests/cases/test/GroupTest.php
@@ -18,6 +18,8 @@
use lithium\tests\mocks\test\cases\MockTest;
use lithium\tests\mocks\test\cases\MockTestErrorHandling;
use lithium\tests\mocks\test\cases\MockSkipThrowsException;
+use lithium\tests\mocks\test\cases\MockSetUpThrowsException;
+use lithium\tests\mocks\test\cases\MockTearDownThrowsException;
class GroupTest extends \lithium\test\Unit {
@@ -34,9 +36,14 @@ public function testAddCaseThroughConstructor() {
$group = new Group(compact('data'));
$expected = new Collection(array('data' => array(
- new MockSkipThrowsException(), new MockTest(), new MockTestErrorHandling()
+ new MockSetUpThrowsException(),
+ new MockSkipThrowsException(),
+ new MockTearDownThrowsException(),
+ new MockTest(),
+ new MockTestErrorHandling()
)));
$result = $group->tests();
+
$this->assertEqual($expected, $result);
}
View
4 tests/cases/test/UnitTest.php
@@ -183,7 +183,7 @@ public function testRun() {
'data' => array('expected' => true, 'result' => true),
'file' => realpath($file),
'line' => 14,
- 'assertion' => 'assertTrue',
+ 'assertion' => 'assertTrue'
);
$result = $this->test->run();
$this->assertEqual($expected, $result[0]);
@@ -566,7 +566,7 @@ public function testExceptionCatching() {
$test->run();
$expected = 'tearDown throws exception';
$results = $test->results();
- $this->assertEqual($expected, $results[0]['message']);
+ $this->assertEqual($expected, $results[1]['message']);
}
public function testErrorHandling() {

0 comments on commit d4ae2a6

Please sign in to comment.
Something went wrong with that request. Please try again.