PMC-992
This commit is contained in:
2
phpunit.xml
Normal file → Executable file
2
phpunit.xml
Normal file → Executable file
@@ -52,6 +52,8 @@
|
||||
<env name="MSSQL_DATABASE" value="testexternal" />
|
||||
<env name="MSSQL_USERNAME" value="test" />
|
||||
<env name="MSSQL_PASSWORD" value="test" />
|
||||
<!--Define if we use a populated database-->
|
||||
<env name="POPULATE_DATABASE" value="false" />
|
||||
<!--Performance Mysql test-->
|
||||
<env name="RUN_MYSQL_PERFORMANCE_TESTS" value="false" />
|
||||
<!--Php variables-->
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
/**
|
||||
* Test harness bootstrap that sets up initial defines and builds up the initial database schema
|
||||
*/
|
||||
// Bring in our standard bootstrap
|
||||
|
||||
include_once(__DIR__ . '/../bootstrap/autoload.php');
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// Setup our required defines
|
||||
/**
|
||||
* @todo Migrate to configuration parameters
|
||||
*/
|
||||
@@ -35,20 +34,14 @@ define('PMTABLE_KEY', 'pmtable');
|
||||
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
|
||||
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . '/rbac/engine/data/mysql/');
|
||||
define('PATH_LANGUAGECONT', PATH_DATA . '/META-INF/');
|
||||
define('PM_NEW_PROCESS_SAVE', 1006);
|
||||
define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
||||
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
|
||||
define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
|
||||
define('DB_ADAPTER', 'mysql');
|
||||
define('PATH_RBAC_HOME', PATH_TRUNK . '/rbac/');
|
||||
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
|
||||
define("PATH_CUSTOM_SKINS", PATH_DATA . "skins/");
|
||||
define("PATH_TPL", PATH_CORE . "templates/");
|
||||
|
||||
//timezone
|
||||
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int) (env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
|
||||
|
||||
// Set Time Zone
|
||||
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)(env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
|
||||
ini_set('date.timezone', $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] ? 'UTC' : env('MAIN_TIME_ZONE', 'America/New_York'));
|
||||
define('TIME_ZONE', ini_get('date.timezone'));
|
||||
|
||||
@@ -56,25 +49,28 @@ define('TIME_ZONE', ini_get('date.timezone'));
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
//Overwrite with the Processmaker env.ini configuration used in production environments
|
||||
// Overwrite with the ProcessMaker env.ini configuration used in production environments
|
||||
//@todo: move env.ini configuration to .env
|
||||
ini_set('date.timezone', TIME_ZONE); //Set Time Zone
|
||||
date_default_timezone_set(TIME_ZONE);
|
||||
// Configuration values
|
||||
config(['app.timezone' => TIME_ZONE]);
|
||||
|
||||
//configuration values
|
||||
config([
|
||||
"system.workspace" => SYS_SYS
|
||||
]);
|
||||
// Defining constants related to the workspace
|
||||
define("PATH_DATA_SITE", PATH_DATA . "sites/" . config("system.workspace") . "/");
|
||||
define("PATH_DYNAFORM", PATH_DATA_SITE . "xmlForms/");
|
||||
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
|
||||
define("PATH_DATA_PUBLIC", PATH_DATA_SITE . "public/");
|
||||
|
||||
G::defineConstants();
|
||||
|
||||
// Setup our testexternal database
|
||||
config(['database.connections.testexternal' => [
|
||||
/**
|
||||
* Database configurations
|
||||
*/
|
||||
// Setup connection to database SQLServer
|
||||
config([
|
||||
'database.connections.testexternal' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'database' => 'testexternal',
|
||||
@@ -86,28 +82,22 @@ config(['database.connections.testexternal' => [
|
||||
'prefix' => '',
|
||||
'strict' => true,
|
||||
'engine' => null
|
||||
]]);
|
||||
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
Schema::connection('testexternal')->dropIfExists('test');
|
||||
|
||||
Schema::connection('testexternal')->create('test', function($table) {
|
||||
$table->increments('id');
|
||||
$table->string('value');
|
||||
});
|
||||
DB::connection('testexternal')->table('test')->insert([
|
||||
'value' => 'testvalue'
|
||||
]
|
||||
]);
|
||||
|
||||
// Only do if we are supporting MSSql tests
|
||||
/**
|
||||
* Configuration for MSSQL
|
||||
*/
|
||||
if (env('RUN_MSSQL_TESTS')) {
|
||||
config(['database.connections.mssql' => [
|
||||
config([
|
||||
'database.connections.mssql' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'host' => env('MSSQL_HOST', '127.0.0.1'),
|
||||
'database' => env('MSSQL_DATABASE', 'testexternal'),
|
||||
'username' => env('MSSQL_USERNAME', 'root'),
|
||||
'password' => env('MSSQL_PASSWORD', 'password'),
|
||||
]]);
|
||||
]
|
||||
]);
|
||||
|
||||
Schema::connection('mssql')->dropIfExists('test');
|
||||
Schema::connection('mssql')->create('test', function ($table) {
|
||||
@@ -119,11 +109,23 @@ if (env('RUN_MSSQL_TESTS')) {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for standard ProcessMaker tables
|
||||
*/
|
||||
if (!env('POPULATE_DATABASE')) {
|
||||
// Create a table for define the connection
|
||||
Schema::connection('testexternal')->dropIfExists('test');
|
||||
Schema::connection('testexternal')->create('test', function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('value');
|
||||
});
|
||||
DB::connection('testexternal')->table('test')->insert([
|
||||
'value' => 'testvalue'
|
||||
]);
|
||||
|
||||
// THIS IS FOR STANDARD PROCESSMAKER TABLES
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
DB::unprepared('SET FOREIGN_KEY_CHECKS = 0');
|
||||
$colname = 'Tables_in_' . env('DB_DATABASE');
|
||||
$colname = 'Tables_in_' . env('DB_DATABASE', 'test');
|
||||
$tables = DB::select('SHOW TABLES');
|
||||
$drop = [];
|
||||
foreach ($tables as $table) {
|
||||
@@ -163,6 +165,7 @@ DB::table('OAUTH_ACCESS_TOKENS')->insert([
|
||||
'EXPIRES' => '2017-06-15 17:55:19',
|
||||
'SCOPE' => 'view_processes edit_processes *'
|
||||
]);
|
||||
}
|
||||
|
||||
// We need to manually initialize Propel with our test database
|
||||
Propel::initConfiguration([
|
||||
|
||||
Reference in New Issue
Block a user