PMC-913 All existing Unit Tests are running correctly?
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<directory>./tests/workflow/engine/src/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
<directory suffix="Test.php">./tests/unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Performance">
|
||||
<directory>./tests/Performance/</directory>
|
||||
|
||||
@@ -1,43 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Queue\Console\WorkCommand;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Model\DbSource;
|
||||
use ProcessMaker\Model\Process;
|
||||
use Tests\TestCase;
|
||||
use Propel;
|
||||
use DbConnections;
|
||||
|
||||
class DBQueryTest extends TestCase
|
||||
{
|
||||
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* A basic cache example.
|
||||
*
|
||||
* @return void
|
||||
* Sets up the unit tests.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the execution of a common SQL statement.
|
||||
* @test
|
||||
*/
|
||||
public function testStandardExecuteQuery()
|
||||
{
|
||||
$results = executeQuery("SELECT * FROM USERS WHERE USR_UID = '00000000000000000000000000000001'");
|
||||
$this->assertCount(1, $results);
|
||||
// Note, we check index 1 because results from executeQuery are 1 indexed, not 0 indexed.
|
||||
$this->assertArraySubset([
|
||||
$expected = [
|
||||
'USR_UID' => '00000000000000000000000000000001',
|
||||
'USR_USERNAME' => 'admin'
|
||||
], $results[1]);
|
||||
];
|
||||
$this->assertArraySubset($expected, $results[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the existence of the admin user.
|
||||
* @test
|
||||
*/
|
||||
public function testDBFacadeQuery()
|
||||
{
|
||||
$record = DB::table('USERS')->where([
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
])->first();
|
||||
$record = DB::table('USERS')->where('USR_UID', '=', '00000000000000000000000000000001')->first();
|
||||
$this->assertEquals('admin', $record->USR_USERNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the execution of a SQL statement common to an MySQL external database.
|
||||
* @test
|
||||
*/
|
||||
public function testStandardExecuteQueryWithExternalMySQLDatabase()
|
||||
{
|
||||
// Our test external database is created in our tests/bootstrap.php file
|
||||
@@ -45,12 +58,12 @@ class DBQueryTest extends TestCase
|
||||
$process = factory(Process::class)->create();
|
||||
// Let's create an external DB to ourselves
|
||||
$externalDB = factory(DbSource::class)->create([
|
||||
'DBS_SERVER' => 'localhost',
|
||||
'DBS_SERVER' => config('database.connections.testexternal.host'),
|
||||
'DBS_PORT' => '3306',
|
||||
'DBS_USERNAME' => env('DB_USERNAME'),
|
||||
'DBS_USERNAME' => config('database.connections.testexternal.username'),
|
||||
// Remember, we have to do some encryption here @see DbSourceFactory.php
|
||||
'DBS_PASSWORD' => \G::encrypt( env('DB_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => 'testexternal',
|
||||
'DBS_PASSWORD' => \G::encrypt(env('DB_PASSWORD'), config('database.connections.testexternal.database')) . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => config('database.connections.testexternal.database'),
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
|
||||
@@ -65,9 +78,13 @@ class DBQueryTest extends TestCase
|
||||
$this->assertEquals('testvalue', $results[1]['value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the execution of a SQL statement common to an MSSQL external database.
|
||||
* @test
|
||||
*/
|
||||
public function testStandardExecuteQueryWithExternalMSSqlDatabase()
|
||||
{
|
||||
if(!env('RUN_MSSQL_TESTS')) {
|
||||
if (!env('RUN_MSSQL_TESTS')) {
|
||||
$this->markTestSkipped('MSSQL Related Test Skipped');
|
||||
}
|
||||
// Our test external database is created in our tests/bootstrap.php file
|
||||
@@ -80,8 +97,8 @@ class DBQueryTest extends TestCase
|
||||
'DBS_TYPE' => 'mssql',
|
||||
'DBS_USERNAME' => env('MSSQL_USERNAME'),
|
||||
// Remember, we have to do some encryption here @see DbSourceFactory.php
|
||||
'DBS_PASSWORD' => \G::encrypt( env('MSSQL_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => 'testexternal',
|
||||
'DBS_PASSWORD' => \G::encrypt(env('MSSQL_PASSWORD'), env('MSSQL_DATABASE')) . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => env('MSSQL_DATABASE'),
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
// Now set our process ID
|
||||
|
||||
@@ -1,26 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use PDO;
|
||||
use PHPUnit\Framework\TestCase as TestCaseFramework;
|
||||
use ProcessMaker\Importer\XmlImporter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test case that could instance a workspace DB
|
||||
*
|
||||
*/
|
||||
class WorkflowTestCase extends TestCase
|
||||
class WorkflowTestCase extends TestCaseFramework
|
||||
{
|
||||
private $host;
|
||||
private $user;
|
||||
private $password;
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* Create and install the database.
|
||||
*/
|
||||
protected function setupDB()
|
||||
{
|
||||
$this->host = env("DB_HOST");
|
||||
$this->user = env("DB_USERNAME");
|
||||
$this->password = env("DB_PASSWORD");
|
||||
$this->database = env("DB_DATABASE");
|
||||
//Install Database
|
||||
$pdo0 = new PDO("mysql:host=".DB_HOST, DB_USER, DB_PASS);
|
||||
$pdo0->query('DROP DATABASE IF EXISTS '.DB_NAME);
|
||||
$pdo0->query('CREATE DATABASE '.DB_NAME);
|
||||
$pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER,
|
||||
DB_PASS);
|
||||
$pdo0 = new PDO("mysql:host=".$this->host, $this->user, $this->password);
|
||||
$pdo0->query('DROP DATABASE IF EXISTS '.$this->database);
|
||||
$pdo0->query('CREATE DATABASE '.$this->database);
|
||||
$pdo = new PDO("mysql:host=".$this->host.";dbname=".$this->database, $this->user,
|
||||
$this->password);
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
|
||||
$pdo->exec(file_get_contents(PATH_CORE.'data/mysql/schema.sql'));
|
||||
$pdo->exec(file_get_contents(PATH_RBAC_CORE.'data/mysql/schema.sql'));
|
||||
@@ -39,8 +50,8 @@ class WorkflowTestCase extends TestCase
|
||||
protected function dropDB()
|
||||
{
|
||||
//Install Database
|
||||
$pdo0 = new PDO("mysql:host=".DB_HOST, DB_USER, DB_PASS);
|
||||
$pdo0->query('DROP DATABASE IF EXISTS '.DB_NAME);
|
||||
$pdo0 = new PDO("mysql:host=".$this->host, $this->user, $this->password);
|
||||
$pdo0->query('DROP DATABASE IF EXISTS '.$this->database);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,11 @@ 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('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;
|
||||
@@ -53,11 +58,22 @@ ini_set('date.timezone', TIME_ZONE); //Set Time Zone
|
||||
date_default_timezone_set(TIME_ZONE);
|
||||
config(['app.timezone' => TIME_ZONE]);
|
||||
|
||||
//configuration values
|
||||
config([
|
||||
"system.workspace" => SYS_SYS
|
||||
]);
|
||||
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' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'database' => env('DB_DATABASE', 'testexternal'),
|
||||
'database' => 'testexternal',
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', 'password'),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
@@ -68,11 +84,6 @@ config(['database.connections.testexternal' => [
|
||||
'engine' => null
|
||||
]]);
|
||||
|
||||
//configuration values
|
||||
config([
|
||||
"system.workspace" => SYS_SYS
|
||||
]);
|
||||
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
Schema::connection('testexternal')->dropIfExists('test');
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PmDynaformTest extends TestCase
|
||||
class ReportTablesTest extends TestCase
|
||||
{
|
||||
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Constructor of the class.
|
||||
* Sets up the unit tests.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
|
||||
@@ -37,13 +37,6 @@ class GroupTest extends TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
//Move section
|
||||
global $RBAC;
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission($RBAC->sSystem, '00000000000000000000000000000001');
|
||||
|
||||
$this->setInstanceGroup(new Group());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use ProcessMaker\BusinessModel\Language;
|
||||
use System;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Test the ProcessMaker\BusinessModel\Language class.
|
||||
*/
|
||||
class LanguageTest extends \WorkflowTestCase
|
||||
class LanguageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Language
|
||||
@@ -18,18 +22,35 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->setupDB();
|
||||
$this->getBaseUri();
|
||||
$this->object = new Language;
|
||||
$this->translationEnv = PATH_DATA."META-INF".PATH_SEP."translations.env";
|
||||
$this->translationEnv = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
|
||||
file_exists($this->translationEnv) ? unlink($this->translationEnv) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the unit tests.
|
||||
* Get base uri for rest applications.
|
||||
* @return string
|
||||
*/
|
||||
protected function tearDown()
|
||||
private function getBaseUri()
|
||||
{
|
||||
$this->dropDB();
|
||||
$_SERVER = $this->getServerInformation();
|
||||
$baseUri = System::getServerProtocolHost();
|
||||
|
||||
return $baseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server information.
|
||||
* @return object
|
||||
*/
|
||||
private function getServerInformation()
|
||||
{
|
||||
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
|
||||
$content = file_get_contents($pathData);
|
||||
$serverInfo = unserialize($content);
|
||||
|
||||
return $serverInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,14 +75,14 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
public function testGetLanguageListInstalled()
|
||||
{
|
||||
$this->installLanguage('es', __DIR__.'/processmaker.es.po');
|
||||
$this->installLanguage('es', __DIR__ . '/processmaker.es.po');
|
||||
$list = $this->object->getLanguageList();
|
||||
$this->assertCount(2, $list);
|
||||
$this->assertEquals('en', $list[0]['LANG_ID']);
|
||||
$this->assertEquals('English', $list[0]['LANG_NAME']);
|
||||
$this->assertEquals('es-ES', $list[1]['LANG_ID']);
|
||||
$this->assertEquals('Spanish (Spain)', $list[1]['LANG_NAME']);
|
||||
$this->uninstallLanguage('es', __DIR__.'/processmaker.es.po');
|
||||
$this->uninstallLanguage('es', __DIR__ . '/processmaker.es.po');
|
||||
$list2 = $this->object->getLanguageList();
|
||||
$this->assertCount(1, $list2);
|
||||
}
|
||||
@@ -74,7 +95,7 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
private function installLanguage($lanId, $filename)
|
||||
{
|
||||
copy($filename, PATH_CORE.'content/translations/'.basename($filename));
|
||||
copy($filename, PATH_CORE . 'content/translations/' . basename($filename));
|
||||
$language = \LanguagePeer::retrieveByPK($lanId);
|
||||
$language->setLanEnabled(1);
|
||||
$language->save();
|
||||
@@ -89,7 +110,7 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
private function uninstallLanguage($lanId, $filename)
|
||||
{
|
||||
unlink(PATH_CORE.'content/translations/'.basename($filename));
|
||||
unlink(PATH_CORE . 'content/translations/' . basename($filename));
|
||||
$language = \LanguagePeer::retrieveByPK($lanId);
|
||||
$language->setLanEnabled(0);
|
||||
$language->save();
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use G;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Skins Tests
|
||||
*/
|
||||
class SkinsTest extends \WorkflowTestCase
|
||||
class SkinsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Skins
|
||||
@@ -17,9 +20,7 @@ class SkinsTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->cleanShared();
|
||||
$this->setupDB();
|
||||
$this->object = new Skins;
|
||||
$this->object = new Skins();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,8 @@ class SkinsTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->cleanShared();
|
||||
$this->dropDB();
|
||||
G::rm_dir(PATH_DATA . 'skins');
|
||||
mkdir(PATH_DATA . 'skins');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,12 +62,7 @@ class SkinsTest extends \WorkflowTestCase
|
||||
{
|
||||
$this->object->createSkin('test', 'test');
|
||||
$this->object->createSkin(
|
||||
'test2',
|
||||
'test2',
|
||||
'Second skin',
|
||||
'ProcessMaker Team',
|
||||
'current',
|
||||
'neoclassic'
|
||||
'test2', 'test2', 'Second skin', 'ProcessMaker Team', 'current', 'neoclassic'
|
||||
);
|
||||
$skins = $this->object->getSkins();
|
||||
$this->assertCount(4, $skins);
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\WebEntryEvent;
|
||||
use ProcessMaker\Importer\XmlImporter;
|
||||
use System;
|
||||
use Tests\WorkflowTestCase;
|
||||
|
||||
/**
|
||||
* WebEntryEventTest test
|
||||
*/
|
||||
class WebEntryEventTest extends \WorkflowTestCase
|
||||
class WebEntryEventTest extends WorkflowTestCase
|
||||
{
|
||||
const SKIP_VALUE = '&SKIP_VALUE%';
|
||||
|
||||
@@ -26,20 +30,19 @@ class WebEntryEventTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
//to do: This is excluded because requires more changes
|
||||
$this->markTestIncomplete();
|
||||
|
||||
$this->getBaseUri();
|
||||
$this->setupDB();
|
||||
$this->processUid = $this->import(__DIR__.'/WebEntryEventTest.pmx');
|
||||
$this->processUid2 = $this->import(__DIR__.'/WebEntryEventTest2.pmx');
|
||||
$this->object = new WebEntryEvent;
|
||||
$this->setTranslation('ID_INVALID_VALUE_CAN_NOT_BE_EMPTY',
|
||||
'ID_INVALID_VALUE_CAN_NOT_BE_EMPTY({0})');
|
||||
$this->setTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED',
|
||||
'ID_UNDEFINED_VALUE_IS_REQUIRED({0})');
|
||||
$this->setTranslation('ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST',
|
||||
'ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST({0})');
|
||||
$this->setTranslation('ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES',
|
||||
'ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES({0},{1})');
|
||||
$this->setTranslation('ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY',
|
||||
'ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY({0},{1})');
|
||||
$this->processUid = $this->import(__DIR__ . '/WebEntryEventTest.pmx');
|
||||
$this->processUid2 = $this->import(__DIR__ . '/WebEntryEventTest2.pmx');
|
||||
$this->object = new WebEntryEvent();
|
||||
$this->setTranslation('ID_INVALID_VALUE_CAN_NOT_BE_EMPTY', 'ID_INVALID_VALUE_CAN_NOT_BE_EMPTY({0})');
|
||||
$this->setTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED', 'ID_UNDEFINED_VALUE_IS_REQUIRED({0})');
|
||||
$this->setTranslation('ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST', 'ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST({0})');
|
||||
$this->setTranslation('ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES', 'ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES({0},{1})');
|
||||
$this->setTranslation('ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY', 'ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY({0},{1})');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,10 +50,34 @@ class WebEntryEventTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->dropDB();
|
||||
$this->clearTranslations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base uri for rest applications.
|
||||
* @return string
|
||||
*/
|
||||
private function getBaseUri()
|
||||
{
|
||||
$_SERVER = $this->getServerInformation();
|
||||
$baseUri = System::getServerProtocolHost();
|
||||
|
||||
return $baseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server information.
|
||||
* @return object
|
||||
*/
|
||||
private function getServerInformation()
|
||||
{
|
||||
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
|
||||
$content = file_get_contents($pathData);
|
||||
$serverInfo = unserialize($content);
|
||||
|
||||
return $serverInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ProcessMaker\BusinessModel\WebEntryEvent::getWebEntryEvents
|
||||
* @category HOR-3207:5
|
||||
|
||||
@@ -746,7 +746,13 @@ class Process extends BaseProcess
|
||||
return $aProcesses;
|
||||
}
|
||||
|
||||
public function getCasesCountForProcess($pro_uid)
|
||||
/**
|
||||
* This returns the number of cases for the process.
|
||||
* @param string $pro_uid
|
||||
* @return integer
|
||||
* @see ProcessMaker\Project\Bpmn::canRemove()
|
||||
*/
|
||||
public static function getCasesCountForProcess($pro_uid)
|
||||
{
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn('COUNT(*) AS TOTAL_CASES');
|
||||
|
||||
Reference in New Issue
Block a user