blob: 3a46a4ae7bafe7b9dedb3448e2f349183e9af95f (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php
require __DIR__.'/../../app/Core/Loader.php';
require __DIR__.'/../../app/helpers.php';
require __DIR__.'/../../app/functions.php';
require __DIR__.'/../../app/constants.php';
use Core\Loader;
use Core\Registry;
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
require __DIR__.'/../../vendor/password.php';
}
date_default_timezone_set('UTC');
$loader = new Loader;
$loader->setPath('app');
$loader->setPath('vendor');
$loader->execute();
abstract class Base extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->registry = new Registry;
$this->registry->db = function() { return setup_db(); };
$this->registry->event = function() { return setup_events(); };
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;
}
}
public function tearDown()
{
$this->registry->shared('db')->closeConnection();
}
}
|