From 050bb4351b61d94c9edb45044888c043c58c0b35 Mon Sep 17 00:00:00 2001 From: Lienhart Woitok Date: Thu, 28 Apr 2016 15:23:20 +0200 Subject: [PATCH] [TASK] Add tests for create directories task --- .../Generic/CreateDirectoriesTaskTest.php | 61 +++++++++++++++++++ .../TYPO3/Flow/CreateDirectoriesTaskTest.php | 52 ++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 Tests/Unit/Task/Generic/CreateDirectoriesTaskTest.php create mode 100644 Tests/Unit/Task/TYPO3/Flow/CreateDirectoriesTaskTest.php diff --git a/Tests/Unit/Task/Generic/CreateDirectoriesTaskTest.php b/Tests/Unit/Task/Generic/CreateDirectoriesTaskTest.php new file mode 100644 index 00000000..f8951214 --- /dev/null +++ b/Tests/Unit/Task/Generic/CreateDirectoriesTaskTest.php @@ -0,0 +1,61 @@ +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'); + } +} diff --git a/Tests/Unit/Task/TYPO3/Flow/CreateDirectoriesTaskTest.php b/Tests/Unit/Task/TYPO3/Flow/CreateDirectoriesTaskTest.php new file mode 100644 index 00000000..b580c073 --- /dev/null +++ b/Tests/Unit/Task/TYPO3/Flow/CreateDirectoriesTaskTest.php @@ -0,0 +1,52 @@ +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'); + } + +}