-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSandboxCleanup.php
36 lines (28 loc) · 956 Bytes
/
SandboxCleanup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace PHPChunkit\Test\Listener;
use PDO;
use PHPChunkit\Configuration;
use PHPChunkit\ListenerInterface;
class SandboxCleanup implements ListenerInterface
{
/**
* @var Configuration
*/
private $configuration;
public function __construct(Configuration $configuration)
{
$this->configuration = $configuration;
}
public function execute()
{
$pdo = new PDO('mysql:host=localhost;', 'root', null);
$configDir = sprintf('%s/bin/config', $this->configuration->getRootDir());
$configFilePath = sprintf('%s/databases_test.ini', $configDir);
$configFileBackupPath = sprintf('%s/databases_test.ini.bak', $configDir);
$databases = parse_ini_file($configFilePath);
foreach ($databases as $databaseName) {
$pdo->exec(sprintf('DROP DATABASE IF EXISTS %s', $databaseName));
}
rename($configFileBackupPath, $configFilePath);
}
}