Skip to content

Commit

Permalink
[TASK] Add tests for create directories task
Browse files Browse the repository at this point in the history
  • Loading branch information
liwo committed Apr 28, 2016
1 parent 14e2092 commit 050bb43
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 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');
}

}

0 comments on commit 050bb43

Please sign in to comment.