blob: 2796061083d6abe022779f2d0732d26ebd6be122 (
plain)
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
|
<?php
require __DIR__.'/../../vendor/autoload.php';
require __DIR__.'/../../app/constants.php';
date_default_timezone_set('UTC');
abstract class Base extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);
$pdo->exec('CREATE DATABASE '.DB_NAME);
$pdo = null;
}
else if (DB_DRIVER === 'postgres') {
$pdo = new PDO('pgsql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
$pdo = null;
}
$this->container = new Pimple\Container;
$this->container->register(new ServiceProvider\Database);
$this->container->register(new ServiceProvider\Event);
}
public function tearDown()
{
$this->container['db']->closeConnection();
}
}
|