Skip to content
Browse files

BUG isolate @assets tagged scenarios

This means that all files explicitely created by fixtures will be deleted after scenario.
  • Loading branch information...
1 parent 00f846d commit 5f29392971422e280876e0a004f9360d3b44d74c @michalochman committed Aug 19, 2012
18 features/bootstrap/SilverStripe/Test/Behaviour/SilverStripeContext.php
@@ -117,6 +117,24 @@ public function afterDatabaseDefaults(ScenarioEvent $event)
+ * @AfterScenario @assets
+ */
+ public function afterResetAssets(ScenarioEvent $event)
+ {
+ if (is_array($this->created_files_paths)) {
+ $created_files = array_reverse($this->created_files_paths);
+ foreach ($created_files as $path) {
+ if (is_dir($path)) {
+ \Filesystem::removeFolder($path);
+ } else {
+ @unlink($path);
+ }
+ }
+ }
+ \SapphireTest::empty_temp_db();
+ }
+ /**
* @Given /^there are the following ([^\s]*) records$/
public function thereAreTheFollowingRecords($data_object, PyStringNode $string)
20 features/manage-files.feature
@@ -1,13 +1,10 @@
+@javascript @assets
Feature: Manage files
As a cms author
I want to upload and manage files within the CMS
So that I can insert them into my content efficiently
- # Unfortunately, we need this duplication of "Parent" relationship
- # and specifying the path via "Filename".
- #
# Idea: We could weave the database reset into this through
# saying 'Given there are ONLY the following...'.
Given there are the following Folder records
@@ -21,8 +18,6 @@ Feature: Manage files
Filename: assets/folder2
Name: folder2
- # Will need to copy the files from "files_path" into the assets/ folder.
- # Should be part of the fixture logic, with a special case for "File"
And there are the following File records
@@ -51,25 +46,14 @@ Feature: Manage files
Then the "Files" table should contain "newfolder"
Scenario: I can list files in a folder
- # Slight variation of the "in the '#<selector>' area, specific for GridFields with a title
Given I click on "folder1" in the "Files" table
- # Maybe we can make these composite steps,
- # so have the "... in the 'folder1' table" separate?
Then the "folder1" table should contain "file1"
- # Means the previous match has to be exact rather than partial.
- # I think thats a good idea to avoid false positives.
- # Also: I bet there's a smart way in Behat to handle negations like this.
And the "folder1" table should not contain "file1.1"
- # Requires 'files_path' being set up for Mink,
- # see
Scenario: I can upload a file to a folder
Given I click on "folder1" in the "Files" table
And I press "Upload" button
And I attach the file "testfile.jpg" to "AssetUploadField" with HTML5
- # Good enough for now, unless you can find an easy way
- # to check for both HTML5 uploads and hidden iframes.
- # We use for this.
And I wait for "5000"
And I press "Back to folder" button
Then the "folder1" table should contain "testfile"
@@ -85,8 +69,6 @@ Feature: Manage files
Scenario: I can delete a file
Given I click on "folder1" in the "Files" table
- # Note that the file name in DB and filesystem should be reset from the
- # previous scenario at this point
And I click on "file1" in the "folder1" table
And I press "Delete" button
Then the "folder1" table should not contain "file1"

0 comments on commit 5f29392

Please sign in to comment.
Something went wrong with that request. Please try again.