Merge pull request #99 from chillu/pulls/fix-folder-creation

Fix nested folder fixture creation
This commit is contained in:
Damian Mooyman 2015-10-22 13:32:48 +13:00
commit 6009c5bdbd

View File

@ -550,6 +550,7 @@ class FixtureContext extends BehatContext
if($class == 'Folder' || is_subclass_of($class, 'Folder')) { if($class == 'Folder' || is_subclass_of($class, 'Folder')) {
$parent = \Folder::find_or_make($relativeTargetPath); $parent = \Folder::find_or_make($relativeTargetPath);
$targetPath = $this->joinPaths(ASSETS_PATH, $relativeTargetPath); $targetPath = $this->joinPaths(ASSETS_PATH, $relativeTargetPath);
$data['ID'] = $parent->ID;
} else { } else {
$parent = \Folder::find_or_make(dirname($relativeTargetPath)); $parent = \Folder::find_or_make(dirname($relativeTargetPath));
if(!file_exists($sourcePath)) { if(!file_exists($sourcePath)) {
@ -559,6 +560,8 @@ class FixtureContext extends BehatContext
$sourcePath $sourcePath
)); ));
} }
$data['ParentID'] = $parent->ID;
// Load file into APL and retrieve tuple // Load file into APL and retrieve tuple
$asset = $this->getAssetStore()->setFromLocalFile( $asset = $this->getAssetStore()->setFromLocalFile(
$sourcePath, $sourcePath,
@ -575,13 +578,9 @@ class FixtureContext extends BehatContext
$url = $this->getAssetStore()->getAsURL($asset['Filename'], $asset['Hash'], $asset['Variant']); $url = $this->getAssetStore()->getAsURL($asset['Filename'], $asset['Hash'], $asset['Variant']);
$targetPath = $this->joinPaths(BASE_PATH, substr($url, strlen(\Director::baseURL()))); $targetPath = $this->joinPaths(BASE_PATH, substr($url, strlen(\Director::baseURL())));
} }
unset($data['Filename']);
if(!isset($data['Name'])) { if(!isset($data['Name'])) {
$data['Name'] = basename($relativeTargetPath); $data['Name'] = basename($relativeTargetPath);
} }
if($parent) {
$data['ParentID'] = $parent->ID;
}
$this->createdFilesPaths[] = $targetPath; $this->createdFilesPaths[] = $targetPath;