-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathEZTestCase.php
More file actions
78 lines (64 loc) · 1.87 KB
/
EZTestCase.php
File metadata and controls
78 lines (64 loc) · 1.87 KB
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
<?php
namespace ezsql\Tests;
abstract class EZTestCase extends \PHPUnit\Framework\TestCase
{
/**
* constant string user name
*/
const TEST_DB_USER = 'ez_test';
/**
* constant string password
*/
const TEST_DB_PASSWORD = 'ezTest';
/**
* constant database name
*/
const TEST_DB_NAME = 'ez_test';
/**
* constant database host
*/
const TEST_DB_HOST = 'localhost';
/**
* constant database connection charset
*/
const TEST_DB_CHARSET = 'utf8';
/**
* constant string database port
*/
const TEST_DB_PORT = '5432';
/**
* constant string path and file name of the SQLite test database
*/
const TEST_SQLITE_DB = 'ez_test.sqlite3';
const TEST_SQLITE_DB_DIR = './tests/sqlite/';
protected $errors;
public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext = null)
{
$this->errors[] = compact("errno", "errstr", "errfile", "errline", "errcontext");
}
public function assertError($errstr, $errno)
{
foreach ($this->errors as $error) {
if ($error["errstr"] === $errstr && $error["errno"] === $errno) {
return;
}
}
$this->fail();
}
/**
* Call protected/private method of a class.
*
* @param object &$object Instantiated object that we will run method on.
* @param string $methodName Method name to call
* @param array $parameters Array of parameters to pass into method.
*
* @return mixed Method return.
*/
public function invokeMethod(&$object, $methodName, array $parameters = array())
{
$reflection = new \ReflectionClass(get_class($object));
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs($object, $parameters);
}
}