Skip to content
Browse files

Change homegrown directory management to use Symfony filesystem compo…

…nent. Replaced unneccessary constant
  • Loading branch information...
1 parent abe4ac9 commit 91bbad6217c45643051a35d1aef16ae3498ee3b8 @shrikeh shrikeh committed Mar 3, 2014
Showing with 9 additions and 16 deletions.
  1. +2 −1 composer.json
  2. +7 −15 features/bootstrap/PhpSpecContext.php
View
3 composer.json
@@ -29,7 +29,8 @@
"require-dev": {
"behat/behat": "~2.5",
- "bossa/phpspec2-expect": "dev-master"
+ "bossa/phpspec2-expect": "dev-master",
+ "symfony/filesystem": "~2.1"
},
"suggest": {
View
22 features/bootstrap/PhpSpecContext.php
@@ -3,6 +3,7 @@
use Behat\Behat\Context\BehatContext;
use Behat\Gherkin\Node\PyStringNode;
use PhpSpec\Console\Application;
+use Symfony\Component\Filesystem\Filesystem;
class PhpSpecContext extends BehatContext
{
@@ -23,13 +24,12 @@ public function createWorkDir()
{
$this->workDir = sprintf(
- '%s%s%s%S',
+ '%s/%s/',
sys_get_temp_dir(),
- DIRECTORY_SEPARATOR,
- uniqid('PhpSpecContext_'),
- DIRECTORY_SEPARATOR
+ uniqid('PhpSpecContext_')
);
- mkdir($this->workDir, 0777, true);
+ $fs = new Filesystem();
+ $fs->mkdir($this->workDir, 0777);
chdir($this->workDir);
}
@@ -38,16 +38,8 @@ public function createWorkDir()
*/
public function removeWorkDir()
{
- $workDir = new RecursiveDirectoryIterator($this->workDir, FilesystemIterator::SKIP_DOTS);
- $iterator = new RecursiveIteratorIterator($workDir, RecursiveIteratorIterator::CHILD_FIRST);
- foreach ($iterator as $file) {
- if ($file->isDir()) {
- rmdir($file->getPathname());
- } else {
- unlink($file->getPathname());
- }
- }
- rmdir($this->workDir);
+ $fs = new Filesystem();
+ $fs->remove($this->workDir);
}
/**

0 comments on commit 91bbad6

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