-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-runner.php
More file actions
63 lines (57 loc) · 1.72 KB
/
test-runner.php
File metadata and controls
63 lines (57 loc) · 1.72 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
<?php
/*
|--------------------------------------------------------------------------
| Test runner
|--------------------------------------------------------------------------
| this script is made for running all unit test under all the supported DBMS
|
*/
function bootLaravel()
{
require __DIR__ . '/vendor/autoload.php';
$laravel_app = require __DIR__ . '/../../../bootstrap/start.php';
$laravel_app->boot();
}
/**
* @param $current_connection
* @param $config_file_path
* @return string
*/
function replaceCurrentConnection($current_connection, $config_file_path)
{
$connection_under_test = "'default' => '{$current_connection}'";
$content = preg_replace(
"/'default' => '[a-zA-Z]*'/",
$connection_under_test,
File::get($config_file_path)
);
File::put($config_file_path, $content);
return $connection_under_test;
}
/**
* @param $connection_under_test
*/
function printMessage($connection_under_test)
{
echo "\n\n";
echo "\033[32m#############################################\n";
echo "## Running all tests with {$connection_under_test} DBMS ##\n";
echo "#############################################\n\n";
echo "\033[0m";
}
$connections = [
'sqlite',
'mysql',
'pgsql'
];
$config_file_path = __DIR__ . '/src/config/testing/database.php';
// the default testing connection
$default_connection = 'sqlite';
bootLaravel();
foreach($connections as $current_connection)
{
$connection_under_test = replaceCurrentConnection($current_connection, $config_file_path);
printMessage($current_connection);
passthru("vendor/bin/phpunit");
$connection_under_test = replaceCurrentConnection($default_connection, $config_file_path);
}