Skip to content

Commit

Permalink
tests: cleanup temp dir after run
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 9, 2015
1 parent fd3ae22 commit 709ee07
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
composer.lock
vendor
tests/temp
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<phpunit
bootstrap="vendor/autoload.php"
bootstrap="tests/bootstrap.php"
colors="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
Expand Down
13 changes: 1 addition & 12 deletions tests/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,9 @@ class ContainerFactory
public function create()
{
$configurator = new Configurator;
$configurator->setTempDirectory($this->createAndReturnTempDir());
$configurator->setTempDirectory(TEMP_DIR);
$configurator->addConfig(__DIR__ . '/config/default.neon');
return $configurator->createContainer();
}


/**
* @return string
*/
private function createAndReturnTempDir()
{
$tempDir = __DIR__ . '/temp';
@mkdir($tempDir, 0777, TRUE);
return $tempDir;
}

}
35 changes: 7 additions & 28 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
<?php

namespace Zenify\DoctrineBehaviors\Tests;
include __DIR__ . '/../vendor/autoload.php';

use Nette\Configurator;
use Nette\DI\Container;

$tempDir = __DIR__ . '/temp/' . getmypid();
define('TEMP_DIR', $tempDir);
@mkdir($tempDir, 0777, TRUE);

class ContainerFactory
{

/**
* @return Container
*/
public function create()
{
$configurator = new Configurator;
$configurator->setTempDirectory($this->createAndReturnTempDir());
$configurator->addConfig(__DIR__ . '/config/default.neon');
return $configurator->createContainer();
}


/**
* @return string
*/
private function createAndReturnTempDir()
{
$tempDir = __DIR__ . '/temp';
@mkdir($tempDir, 0777, TRUE);
return $tempDir;
}

}
register_shutdown_function(function() {
Nette\Utils\FileSystem::delete(__DIR__ . '/temp');
});

0 comments on commit 709ee07

Please sign in to comment.