Skip to content

Commit ee1e2e3

Browse files
committed
Remove reflection
1 parent 9b28263 commit ee1e2e3

File tree

8 files changed

+105
-115
lines changed

8 files changed

+105
-115
lines changed

tests/Config.php.dist

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,26 @@ class Config
99
* @var array
1010
*/
1111
public static $config = array(
12-
array(
13-
'dbengine' => 'MySQL', // 'MySQL', 'SQLServer', 'PostgreSQL' or 'SQLite'
12+
'MySQL' => array(
1413
'hostname' => '{{test_hostname}}', // 'localhost' for MySQL, '(Local)' for SQLServer, empty for SQLite
1514
'username' => '{{test_username}}', // May be empty on SQLServer or SQLite
1615
'password' => '{{test_password}}', // May be empty on SQLServer or SQLite
1716
'database' => '{{test_database}}', // NB: Use an empty database, data will be LOST!
1817
),
1918
/* Uncomment and update for any databases you want to use.
20-
array(
21-
'dbengine' => 'PostgreSQL',
19+
'PostgreSQL' => array(
2220
'hostname' => '{{test_hostname}}',
2321
'username' => '{{test_username}}',
2422
'password' => '{{test_password}}',
2523
'database' => '{{test_database}}',
2624
),
27-
array(
28-
'dbengine' => 'SQLite',
25+
'SQLite' => array(
2926
'hostname' => '{{test_hostname}}',
3027
'username' => '{{test_username}}',
3128
'password' => '{{test_password}}',
3229
'database' => '{{test_database}}',
3330
),
34-
array(
35-
'dbengine' => 'SQLServer',
31+
'SQLServer' => array(
3632
'hostname' => '{{test_hostname}}',
3733
'username' => '{{test_username}}',
3834
'password' => '{{test_password}}',

tests/Config.php.travis

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,19 @@ class Config
99
* @var array
1010
*/
1111
public static $config = array(
12-
/* MySQL is disabled because v5.7 is required for all tests to pass,
13-
and Travis only has up to MySQL 5.6 installed by default. This
14-
will be runnable once we have a test suite that adapts to the
15-
available MySQL version. See: https://github.com/mevdschee/php-crud-api/issues/194
16-
array(
17-
'dbengine' => 'MySQL',
12+
'MySQL' => array(
1813
'hostname' => 'localhost',
1914
'username' => 'root',
2015
'password' => 'travis',
2116
'database' => 'testing',
2217
),
23-
*/
24-
array(
25-
'dbengine' => 'PostgreSQL',
18+
'PostgreSQL' => array(
2619
'hostname' => 'localhost',
2720
'username' => 'postgres',
2821
'password' => '',
2922
'database' => 'testing',
3023
),
31-
array(
32-
'dbengine' => 'SQLite',
24+
'SQLite' => array(
3325
'hostname' => '',
3426
'username' => '',
3527
'password' => '',

tests/MysqlTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class MysqlTest extends Tests
66
{
7+
const NAME = 'MySQL';
8+
79
/**
810
* Connects to the Database
911
*

tests/PostgresqlTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class PostgresqlTest extends Tests
66
{
7+
const NAME = 'PostgreSQL';
8+
79
/**
810
* Connects to the Database
911
*

tests/SqlServerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class SqlServerTest extends Tests
66
{
7+
const NAME = 'SQLServer';
8+
79
/**
810
* Connects to the Database
911
*

tests/SqliteTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class SqliteTest extends Tests
66
{
7+
const NAME = 'SQLite';
8+
79
/**
810
* Connects to the Database
911
*

tests/TestBase.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,12 @@
44

55
abstract class TestBase extends PHPUnit_Framework_TestCase
66
{
7-
protected function getConfig()
8-
{
9-
$dbengine = strtolower(substr(get_called_class(),0,-4));
10-
foreach (Config::$config as $database) {
11-
if (strtolower($database['dbengine']) == $dbengine) {
12-
if ($database['database']!='{{test_database}}') {
13-
return $database;
14-
}
15-
}
16-
}
17-
self::markTestSkipped("Configuration for '{$dbengine}' in 'Config.php' not found.");
18-
return false;
19-
}
20-
217
public static function setUpBeforeClass()
228
{
23-
$config = self::getConfig();
9+
if (!Config::$config || !isset(Config::$config[static::NAME])) {
10+
self::markTestSkipped("Configuration in 'Config.php' not found.");
11+
}
12+
$config = Config::$config[static::NAME];
2413
$db = static::connect($config);
2514
static::checkVersion($db);
2615
$capabilities = static::getCapabilities($db);
@@ -37,6 +26,10 @@ public static function setUpBeforeClass()
3726
const GIS = 1;
3827
const JSON = 2;
3928

29+
public abstract function connect($db);
30+
31+
public abstract function disconnect($db);
32+
4033
public abstract function checkVersion($db);
4134

4235
public abstract function getCapabilities($db);

0 commit comments

Comments
 (0)