diff --git a/tests/application/example.test.php b/application/tests/example.test.php similarity index 86% rename from tests/application/example.test.php rename to application/tests/example.test.php index d7b3fcb2..d9b330c0 100644 --- a/tests/application/example.test.php +++ b/application/tests/example.test.php @@ -9,7 +9,7 @@ class TestExample extends PHPUnit_Framework_TestCase { */ public function testSomethingIsTrue() { - $this->assertTrue(true); + $this->assertTrue(true); } } \ No newline at end of file diff --git a/build.xml b/build.xml deleted file mode 100644 index 8806d027..00000000 --- a/build.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - bundles/laravel-tests/cases - - - \ No newline at end of file diff --git a/laravel/cli/dependencies.php b/laravel/cli/dependencies.php index 56435ab4..5ce03fd0 100644 --- a/laravel/cli/dependencies.php +++ b/laravel/cli/dependencies.php @@ -46,6 +46,16 @@ return new Tasks\Session\Manager; }); +/** + * The "test" task is responsible for running the unit tests for + * the application, bundles, and the core framework itself. + * It provides a nice wrapper around PHPUnit. + */ +IoC::singleton('task: test', function() +{ + return new Tasks\Test\Runner; +}); + /** * The bundle repository is responsible for communicating with * the Laravel bundle sources to get information regarding any @@ -58,8 +68,8 @@ /** * The bundle publisher is responsible for publishing bundle - * assets and tests to their correct directories within the - * application, such as the web accessible directory. + * assets to their correct directories within the install, + * such as the web accessible directory. */ IoC::singleton('bundle.publisher', function() { diff --git a/laravel/cli/tasks/bundle/publisher.php b/laravel/cli/tasks/bundle/publisher.php index 3454b18b..5fc30c84 100644 --- a/laravel/cli/tasks/bundle/publisher.php +++ b/laravel/cli/tasks/bundle/publisher.php @@ -18,9 +18,7 @@ public function publish($bundle) $this->move($path.'public', PUBLIC_PATH.'bundles'.DS.$bundle); - $this->move($path.'tests', TESTS_PATH.'cases'.DS.'bundles'.DS.$bundle); - - echo "Assets and tests published for bundle [$bundle].".PHP_EOL; + echo "Assets published for bundle [$bundle].".PHP_EOL; } /** diff --git a/laravel/cli/tasks/test/runner.php b/laravel/cli/tasks/test/runner.php new file mode 100644 index 00000000..75704fa2 --- /dev/null +++ b/laravel/cli/tasks/test/runner.php @@ -0,0 +1,66 @@ +bundle(array(DEFAULT_BUNDLE)); + } + + /** + * Run the tests for a given bundle. + * + * @param array $arguments + * @return void + */ + public function bundle($arguments = array()) + { + // To run PHPUnit for the application, bundles, and the framework + // from one task, we'll dynamically stub PHPUnit.xml files via + // the task and point the test suite to the correct directory + // based on what was requested. + $this->stub(Bundle::path($arguments[0]).'tests'); + + $this->test(); + } + + /** + * Run PHPUnit with the temporary XML configuration. + * + * @return void + */ + protected function test() + { + // We'll simply fire off PHPUnit with the configuration switch + // pointing to our temporary configuration file. This allows + // us to flexibly run tests for any setup. + passthru('phpunit -c '.BASE_PATH.'phpunit.xml'); + + @unlink(BASE_PATH.'phpunit.xml'); + } + + /** + * Write a stub phpunit.xml file to the base directory. + * + * @param string $directory + * @return void + */ + protected function stub($directory) + { + $stub = File::get(SYS_PATH.'cli/tasks/test/stub.xml'); + + $stub = str_replace('{{directory}}', $directory, $stub); + + File::put(BASE_PATH.'phpunit.xml', $stub); + } + +} \ No newline at end of file diff --git a/phpunit.xml b/laravel/cli/tasks/test/stub.xml similarity index 74% rename from phpunit.xml rename to laravel/cli/tasks/test/stub.xml index 6962d975..297476c6 100644 --- a/phpunit.xml +++ b/laravel/cli/tasks/test/stub.xml @@ -3,7 +3,7 @@ backupGlobals="false"> - tests + {{directory}} \ No newline at end of file diff --git a/tests/application/.gitignore b/tests/application/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/bundles/.gitignore b/tests/bundles/.gitignore deleted file mode 100644 index e69de29b..00000000