diff --git a/dev/TestRunner.php b/dev/TestRunner.php index fa7b869b3..483165cfc 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -42,6 +42,7 @@ class TestRunner extends Controller { 'coverage/module/$ModuleName' => 'coverageModule', 'coverage/$TestCase!' => 'coverageOnly', 'coverage' => 'coverageAll', + 'sessionloadyml' => 'sessionloadyml', 'startsession' => 'startsession', 'endsession' => 'endsession', 'cleanupdb' => 'cleanupdb', @@ -377,7 +378,50 @@ HTML;
  • Start a new test session
  • "; } - + + function sessionloadyml() { + // Load incremental YAML fixtures + // TODO: We will probably have to filter out the admin member here, + // as it is supplied by Bare.yml + if(Director::isLive()) { + return "

    sessionloadyml can only be used on dev and test sites

    "; + } + if (!SapphireTest::using_temp_db()) { + return "

    Please load /dev/tests/startsession first

    "; + } + + $fixtureFile = isset($_GET['fixture']) ? $_GET['fixture'] : null; + if (empty($fixtureFile)) { + $me = Director::baseURL() . "/dev/tests/sessionloadyml"; + return << +

    Enter a fixture file name to load a new YAML fixture into the session.

    +

    Fixture file

    + +

    + +HTML; + } + // Validate fixture file + $realFile = realpath(BASE_PATH.'/'.$fixtureFile); + $baseDir = realpath(Director::baseFolder()); + if(!$realFile || !file_exists($realFile)) { + return "

    Fixture file doesn't exist

    "; + } else if(substr($realFile,0,strlen($baseDir)) != $baseDir) { + return "

    Fixture file must be inside $baseDir

    "; + } else if(substr($realFile,-4) != '.yml') { + return "

    Fixture file must be a .yml file

    "; + } else if(!preg_match('/^([^\/.][^\/]+)\/tests\//', $fixtureFile)) { + return "

    Fixture file must be inside the tests subfolder of one of your modules.

    "; + } + + // Fixture + $fixture = new YamlFixture($fixtureFile); + $fixture->saveIntoDatabase(); + + return "

    Loaded fixture '$fixtureFile' into session

    "; + } + function setUp() { // The first DB test will sort out the DB, we don't have to SSViewer::flush_template_cache();