Permalink
Browse files

Added Base Integration test class and unit testing of said class.

  • Loading branch information...
1 parent 25e5f82 commit 0fe57ca47dfe4636de9592ce3f3e0afbc8f3bcfd @indiefan indiefan committed with gwoo Mar 9, 2010
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\test;
+
+class Integration extends \lithium\test\Unit {
+
+ /**
+ * Auto init for applying Integration filter
+ *
+ * @return void
+ */
+ protected function _init() {
+ parent::_init();
+
+ $this->applyFilter('run', function($self, $params, $chain) {
+ $before = $self->results();
+
+ $chain->next($self, $params, $chain);
+
+ $after = $self->results();
+
+ while (count($after) > count($before)) {
+ $result = array_pop($after);
+ if ($result['result'] == 'fail') {
+ return false;
+ }
+ }
+ });
+ }
+}
+
+?>
@@ -536,7 +536,7 @@ protected function _result($type, $info, array $options = array()) {
*
* @param string $method The name of the test method to run.
* @param array $options
- * @return void
+ * @return void | false
*/
protected function _runTestMethod($method, $options) {
try {
@@ -547,7 +547,7 @@ protected function _runTestMethod($method, $options) {
}
$params = compact('options', 'method');
- $this->_filter(__CLASS__ . '::run', $params, function($self, $params, $chain) {
+ $passed = $this->_filter(__CLASS__ . '::run', $params, function($self, $params, $chain) {
try {
$method = $params['method'];
$lineFlag = __LINE__ + 1;
@@ -557,6 +557,8 @@ protected function _runTestMethod($method, $options) {
}
});
$this->tearDown();
+
+ return $passed;
}
/**
@@ -797,6 +799,15 @@ protected function _cleanUp($path = null) {
($item->isDir()) ? rmdir($item->getPathname()) : unlink($item->getPathname());
}
}
+
+ /**
+ * Returns the current results
+ *
+ * @return array The Results, currently
+ */
+ public function results() {
+ return $this->_results;
+ }
}
?>
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\tests\cases\test;
+
+use \lithium\tests\mocks\test\MockIntegrationTest;
+
+class IntegrationTest extends \lithium\test\Unit {
+
+ public function testIntegrationHaltsOnFail() {
+ $test = new MockIntegrationTest();
+
+ $expected = 2;
+ $report = $test->run();
+ $result = count($report);
+
+ $this->assertEqual($expected, $result);
+ }
+}
+
+?>
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\tests\mocks\test;
+
+class MockIntegrationTest extends \lithium\test\Integration {
+
+ public function testPass() {
+ $this->assertTrue(true);
+ }
+
+ public function testFail() {
+ $this->assertTrue(false);
+ }
+
+ public function testAnotherPass() {
+ $this->assertTrue(true);
+ }
+}
+
+?>

0 comments on commit 0fe57ca

Please sign in to comment.