Skip to content

Commit

Permalink
Merge pull request #26 from netlogix/bugfix/create-directories
Browse files Browse the repository at this point in the history
[BUGFIX] Fix creating shared/Data directories in Flow application
  • Loading branch information
helhum authored Jun 10, 2016
2 parents cef0f0d + 050bb43 commit 45f36d7
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 2 deletions.
61 changes: 61 additions & 0 deletions Tests/Unit/Task/Generic/CreateDirectoriesTaskTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
namespace TYPO3\Surf\Tests\Unit\Task\Generic;

/* *
* This script belongs to the TYPO3 project "TYPO3 Surf". *
* *
* */

use TYPO3\Surf\Task\Generic\CreateDirectoriesTask;
use TYPO3\Surf\Tests\Unit\Task\BaseTaskTest;

/**
* Class CreateDirectoriesTaskTest
*/
class CreateDirectoriesTaskTest extends BaseTaskTest
{

/**
* @var CreateDirectoriesTask
*/
protected $task;

protected function setUp()
{
parent::setUp();
$this->application = new \TYPO3\Surf\Application\TYPO3\CMS('TestApplication');
$this->application->setDeploymentPath('/home/jdoe/app');
}

/**
* @return CreateDirectoriesTask
*/
protected function createTask()
{
return new CreateDirectoriesTask();
}

/**
* @test
*/
public function createsDirectoriesInReleasePath()
{
$options = array('directories' => array('media'));
$this->task->execute($this->node, $this->application, $this->deployment, $options);

$this->assertCommandExecuted("cd {$this->deployment->getApplicationReleasePath($this->application)}");
$this->assertCommandExecuted('mkdir -p media');
}

/**
* @test
*/
public function createsDirectoriesInCustomPath()
{
$options = array('directories' => array('media'), 'baseDirectory' => '/foo/bar');
$this->task->execute($this->node, $this->application, $this->deployment, $options);

$this->assertCommandExecuted('cd /foo/bar');
$this->assertCommandExecuted('mkdir -p media');
}
}
52 changes: 52 additions & 0 deletions Tests/Unit/Task/TYPO3/Flow/CreateDirectoriesTaskTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace TYPO3\Surf\Tests\Unit\Task\TYPO3\Flow;

/* *
* This script belongs to the TYPO3 project "TYPO3 Surf". *
* *
* */

use TYPO3\Surf\Task\TYPO3\Flow\CreateDirectoriesTask;
use TYPO3\Surf\Tests\Unit\Task\BaseTaskTest;

/**
* Class CreateDirectoriesTaskTest
*/
class CreateDirectoriesTaskTest extends BaseTaskTest
{

/**
* @var CreateDirectoriesTask
*/
protected $task;

protected function setUp()
{
parent::setUp();
$this->application = new \TYPO3\Surf\Application\TYPO3\CMS('TestApplication');
$this->application->setDeploymentPath('/home/jdoe/app');
}

/**
* @return CreateDirectoriesTask
*/
protected function createTask()
{
return new CreateDirectoriesTask();
}

/**
* @test
*/
public function createsDirectoriesInDeploymentRoot()
{
$options = array();
$this->task->execute($this->node, $this->application, $this->deployment, $options);

$this->assertCommandExecuted("cd {$this->application->getDeploymentPath()}");
$this->assertCommandExecuted('mkdir -p shared/Data/Logs');
$this->assertCommandExecuted('mkdir -p shared/Data/Persistent');
$this->assertCommandExecuted('mkdir -p shared/Configuration');
}

}
4 changes: 3 additions & 1 deletion src/Task/Generic/CreateDirectoriesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public function execute(Node $node, Application $application, Deployment $deploy
return;
}

$baseDirectory = isset($options['baseDirectory']) ? $options['baseDirectory'] : $deployment->getApplicationReleasePath($application);

$commands = array(
'cd ' . $deployment->getApplicationReleasePath($application)
'cd ' . $baseDirectory
);
foreach ($options['directories'] as $path) {
$commands[] = 'mkdir -p ' . $path;
Expand Down
3 changes: 2 additions & 1 deletion src/Task/TYPO3/Flow/CreateDirectoriesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function execute(Node $node, Application $application, Deployment $deploy
'shared/Data/Logs',
'shared/Data/Persistent',
'shared/Configuration'
)
),
'baseDirectory' => $application->getDeploymentPath()
);
parent::execute($node, $application, $deployment, $options);
}
Expand Down

0 comments on commit 45f36d7

Please sign in to comment.