From 0d6cb295c468bc12f76104ee08b33afdfc5d4605 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 19 Oct 2010 00:54:31 +0000 Subject: [PATCH] Added dev/tests/emptydb to clear out test session databases. (from r109099) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112777 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/TestRunner.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 645a7fed5..8ccd88e0f 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -46,6 +46,7 @@ class TestRunner extends Controller { 'startsession' => 'startsession', 'endsession' => 'endsession', 'cleanupdb' => 'cleanupdb', + 'emptydb' => 'emptydb', 'module/$ModuleName' => 'module', 'all' => 'all', 'build' => 'build', @@ -387,6 +388,24 @@ HTML; } } + function emptydb() { + if(SapphireTest::using_temp_db()) { + SapphireTest::empty_temp_db(); + + if(isset($_GET['fixture']) && ($fixtureFile = $_GET['fixture'])) { + $fixture = new YamlFixture($fixtureFile); + $fixture->saveIntoDatabase(); + return "

Re-test the test database with fixture '$fixtureFile'. Time to start testing; where would you like to start?

"; + + } else { + return "

Re-test the test database. Time to start testing; where would you like to start?

"; + } + + } else { + return "

dev/tests/emptydb can only be used with a temporary database. Perhaps you should use dev/tests/startsession first?

"; + } + } + function endsession() { SapphireTest::kill_temp_db(); DB::set_alternative_database_name(null);