From 3a292d796be99662d917813c7119066bc5c42781 Mon Sep 17 00:00:00 2001 From: Jeffrey Guo Date: Fri, 5 Feb 2016 16:20:53 +1300 Subject: [PATCH] Revert: API Update for filesystem refactor [15b491e] --- composer.json | 2 +- .../BehatExtension/Context/BasicContext.php | 10 ++++---- .../BehatExtension/Context/FixtureContext.php | 23 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index f26cf7f..b6b95a3 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "symfony/yaml": "~2.0", "symfony/finder": "~2.0", "silverstripe/testsession": "*", - "silverstripe/framework": "^4.0.0" + "silverstripe/framework": "~3.1" }, "autoload": { diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 2e06e90..008ddc6 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -2,10 +2,13 @@ namespace SilverStripe\BehatExtension\Context; -use Behat\Behat\Context\BehatContext, +use Behat\Behat\Context\ClosuredContextInterface, + Behat\Behat\Context\TranslatedContextInterface, + Behat\Behat\Context\BehatContext, Behat\Behat\Context\Step, Behat\Behat\Event\StepEvent, - Behat\Behat\Event\ScenarioEvent; + Behat\Behat\Event\ScenarioEvent, + Behat\Behat\Exception\PendingException; use Behat\Mink\Driver\Selenium2Driver; @@ -265,9 +268,8 @@ JS; */ public function cleanAssetsAfterScenario(ScenarioEvent $event) { foreach(\File::get() as $file) { - $file->delete(); + if(file_exists($file->getFullPath())) $file->delete(); } - \Filesystem::removeFolder(ASSETS_PATH, true); } public function takeScreenshot(StepEvent $event) { diff --git a/src/SilverStripe/BehatExtension/Context/FixtureContext.php b/src/SilverStripe/BehatExtension/Context/FixtureContext.php index e365e8b..112d9cf 100644 --- a/src/SilverStripe/BehatExtension/Context/FixtureContext.php +++ b/src/SilverStripe/BehatExtension/Context/FixtureContext.php @@ -2,11 +2,17 @@ namespace SilverStripe\BehatExtension\Context; -use Behat\Behat\Context\BehatContext, +use Behat\Behat\Context\ClosuredContextInterface, + Behat\Behat\Context\TranslatedContextInterface, + Behat\Behat\Context\BehatContext, + Behat\Behat\Context\Step, + Behat\Behat\Event\StepEvent, + Behat\Behat\Event\FeatureEvent, Behat\Behat\Event\ScenarioEvent, + Behat\Behat\Exception\PendingException, + Behat\Mink\Driver\Selenium2Driver, Behat\Gherkin\Node\PyStringNode, - Behat\Gherkin\Node\TableNode, - SilverStripe\Filesystem\Storage\AssetStore; + Behat\Gherkin\Node\TableNode; // PHPUnit require_once 'PHPUnit/Autoload.php'; @@ -542,7 +548,8 @@ class FixtureContext extends BehatContext protected function prepareAsset($class, $identifier, $data = null) { if(!$data) $data = array(); $relativeTargetPath = (isset($data['Filename'])) ? $data['Filename'] : $identifier; - $relativeTargetPath = preg_replace('/^' . ASSETS_DIR . '\/?/', '', $relativeTargetPath); + $relativeTargetPath = preg_replace('/^' . ASSETS_DIR . '/', '', $relativeTargetPath); + $targetPath = $this->joinPaths(ASSETS_PATH, $relativeTargetPath); $sourcePath = $this->joinPaths($this->getFilesPath(), basename($relativeTargetPath)); // Create file or folder on filesystem @@ -587,14 +594,6 @@ class FixtureContext extends BehatContext return $data; } - /** - * - * @return AssetStore - */ - protected function getAssetStore() { - return singleton('AssetStore'); - } - /** * Converts a natural language class description to an actual class name. * Respects {@link DataObject::$singular_name} variations.