-
Notifications
You must be signed in to change notification settings - Fork 173
/
Loris_PHPUnit_Database_TestCase.php
87 lines (79 loc) · 2.03 KB
/
Loris_PHPUnit_Database_TestCase.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* This contains an abstract class for Loris unit tests which
* will not mock the Database class and therefore will use
* DBUnit to set up the test database's initial state using fixtures.
*
* PHP Version 5
*
* @category Tests
* @package Test
* @author Karolina Marasinska <karolinam.mcin@gmail.com>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://www.github.com/aces/Loris/
*/
use PHPUnit\Framework\TestCase;
/**
* Class Loris_PHPUnit_Databse_TestCase
*
* @category Tests
* @package Test
* @author Karolina Marasinska <karolinam.mcin@gmail.com>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://www.github.com/aces/Loris/
*/
abstract class Loris_PHPUnit_Database_TestCase extends TestCase
{
/**
* PDO connection
*
* Only instantiate _pdo once for test clean-up/fixture load
*
* @var \PDO
*/
static private $_pdo = null;
/**
* LORIS config object
*
* @var NDB_Config
*/
protected $config;
/**
* LORIS Factory object
*
* @var NDB_Factory
*/
protected $factory;
protected $database;
/**
* Setup test
* Checks if tests are run on sandbox, otherwise skips them.
* Some of these tests may be destructive therefore should never be
* run in production
*
* @throws Exception
* @return void
*/
protected function setUp(): void
{
$this->factory = NDB_Factory::singleton();
//if not in sandbox mode do not run tests
if (!$this->factory->settings(CONFIG_XML)->isSandbox()) {
$this->markTestSkipped(
"You are not in 'sandbox' mode.
This is a destructive test, it will be skipped!"
);
}
parent::setUp();
}
/**
* Creates LORIS database connection
*
* @throws DatabaseException
* @return void
*/
protected function createLorisDBConnection()
{
$this->database = $this->factory->database();
}
}