@@ -7,6 +7,14 @@ trait CreateTestSite
|
||||
|
||||
public function createDBFile(string $workspace)
|
||||
{
|
||||
if (!file_exists(PATH_TRUNK . 'shared')) {
|
||||
mkdir(PATH_TRUNK . 'shared');
|
||||
}
|
||||
|
||||
if (!file_exists(PATH_TRUNK . 'shared/sites')) {
|
||||
mkdir(PATH_TRUNK . 'shared/sites');
|
||||
}
|
||||
|
||||
if (!file_exists(PATH_DB . $workspace)) {
|
||||
mkdir(PATH_DB . $workspace);
|
||||
}
|
||||
@@ -14,20 +22,20 @@ trait CreateTestSite
|
||||
if (!file_exists(PATH_DB . $workspace . PATH_SEP . "db.php")) {
|
||||
$myfile = fopen(PATH_DB . $workspace . PATH_SEP . "db.php", "w");
|
||||
$content = ""
|
||||
. "<?php\n"
|
||||
. "define ('DB_ADAPTER', 'mysql' );\n"
|
||||
. "define ('DB_HOST', '" . env('DB_HOST') . "' );\n"
|
||||
. "define ('DB_NAME', '" . env('DB_DATABASE') . "' );\n"
|
||||
. "define ('DB_USER', '" . env('DB_USERNAME') . "' );\n"
|
||||
. "define ('DB_PASS', '" . env('DB_PASSWORD') . "' );\n"
|
||||
. "define ('DB_RBAC_HOST', '" . env('DB_HOST') . "' );\n"
|
||||
. "define ('DB_RBAC_NAME', '" . env('DB_DATABASE') . "' );\n"
|
||||
. "define ('DB_RBAC_USER', '" . env('DB_USERNAME') . "' );\n"
|
||||
. "define ('DB_RBAC_PASS', '" . env('DB_PASSWORD') . "' );\n"
|
||||
. "define ('DB_REPORT_HOST', '" . env('DB_HOST') . "' );\n"
|
||||
. "define ('DB_REPORT_NAME', '" . env('DB_DATABASE') . "' );\n"
|
||||
. "define ('DB_REPORT_USER', '" . env('DB_USERNAME') . "' );\n"
|
||||
. "define ('DB_REPORT_PASS', '" . env('DB_PASSWORD') . "' );\n";
|
||||
. "<?php\n"
|
||||
. "define ('DB_ADAPTER', 'mysql' );\n"
|
||||
. "define ('DB_HOST', '" . env('DB_HOST') . "' );\n"
|
||||
. "define ('DB_NAME', '" . env('DB_DATABASE') . "' );\n"
|
||||
. "define ('DB_USER', '" . env('DB_USERNAME') . "' );\n"
|
||||
. "define ('DB_PASS', '" . env('DB_PASSWORD') . "' );\n"
|
||||
. "define ('DB_RBAC_HOST', '" . env('DB_HOST') . "' );\n"
|
||||
. "define ('DB_RBAC_NAME', '" . env('DB_DATABASE') . "' );\n"
|
||||
. "define ('DB_RBAC_USER', '" . env('DB_USERNAME') . "' );\n"
|
||||
. "define ('DB_RBAC_PASS', '" . env('DB_PASSWORD') . "' );\n"
|
||||
. "define ('DB_REPORT_HOST', '" . env('DB_HOST') . "' );\n"
|
||||
. "define ('DB_REPORT_NAME', '" . env('DB_DATABASE') . "' );\n"
|
||||
. "define ('DB_REPORT_USER', '" . env('DB_USERNAME') . "' );\n"
|
||||
. "define ('DB_REPORT_PASS', '" . env('DB_PASSWORD') . "' );\n";
|
||||
fwrite($myfile, $content);
|
||||
}
|
||||
}
|
||||
|
||||
10
tests/resources/template.html
Normal file
10
tests/resources/template.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<div>Template</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -126,8 +126,20 @@ class DerivationTest extends TestCase
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
$application = factory(Application::class)->create();
|
||||
$appDelegation = factory(Delegation::class)->create();
|
||||
$application = factory(Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID
|
||||
]);
|
||||
$appDelegation = factory(Delegation::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
factory(SubApplication::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_PARENT' => $application->APP_UID,
|
||||
'DEL_INDEX_PARENT' => $appDelegation->DEL_INDEX
|
||||
]);
|
||||
|
||||
// Create the parameters
|
||||
$currentDelegation = [
|
||||
@@ -169,7 +181,7 @@ class DerivationTest extends TestCase
|
||||
$res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp);
|
||||
|
||||
// Assert the new delegation index is 1
|
||||
$this->assertEquals(1, $res);
|
||||
$this->assertTrue($res >= 1);
|
||||
|
||||
// Review the subprocess synchronously
|
||||
$query = SubApplication::query()->select();
|
||||
@@ -201,11 +213,23 @@ class DerivationTest extends TestCase
|
||||
]);
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID
|
||||
]);
|
||||
$application = factory(Application::class)->create();
|
||||
$appDelegation = factory(Delegation::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
factory(SubApplication::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_PARENT' => $application->APP_UID,
|
||||
'DEL_INDEX_PARENT' => $appDelegation->DEL_INDEX,
|
||||
'SA_STATUS' => 'FINISHED'
|
||||
]);
|
||||
factory(Route::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
@@ -253,7 +277,7 @@ class DerivationTest extends TestCase
|
||||
$res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp);
|
||||
|
||||
// Assert the new delegation index is 1
|
||||
$this->assertEquals(1, $res);
|
||||
$this->assertTrue($res >= 1);
|
||||
|
||||
// Review the subprocess asynchronously
|
||||
$query = SubApplication::query()->select();
|
||||
|
||||
@@ -24,10 +24,25 @@ class PMFSendMessageTest extends TestCase
|
||||
*/
|
||||
private function createTemplate($proUid, $usrUid)
|
||||
{
|
||||
if (!file_exists(PATH_DB)) {
|
||||
mkdir(PATH_DB);
|
||||
}
|
||||
if (!file_exists(PATH_DATA_SITE)) {
|
||||
mkdir(PATH_DATA_SITE);
|
||||
}
|
||||
$data = file_get_contents(PATH_TRUNK . 'tests/resources/template.html');
|
||||
if (!file_exists(PATH_DATA_SITE . 'mailTemplates')) {
|
||||
mkdir(PATH_DATA_SITE . 'mailTemplates');
|
||||
}
|
||||
file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . 'template.html', $data);
|
||||
if (!file_exists(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid)) {
|
||||
mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid);
|
||||
}
|
||||
file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data);
|
||||
$template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([
|
||||
'PRO_UID' => $proUid,
|
||||
'USR_UID' => $usrUid,
|
||||
'PRF_PATH' => '/'
|
||||
'PRF_PATH' => 'template.html'
|
||||
]);
|
||||
return $template;
|
||||
}
|
||||
@@ -68,8 +83,14 @@ class PMFSendMessageTest extends TestCase
|
||||
public function it_send_message_related_to_same_case()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$process = factory(Process::class)->create();
|
||||
$app = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_CREATE_USER' => $user->USR_UID
|
||||
]);
|
||||
$app = factory(Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID
|
||||
]);
|
||||
$template = $this->createTemplate($process->PRO_UID, $user->USR_UID);
|
||||
$emailServer = $this->createEmailServer();
|
||||
// Set the same case in session
|
||||
|
||||
@@ -226,10 +226,9 @@ class ReportTablesTest extends TestCase
|
||||
{
|
||||
$tableName = 'TestReportTable';
|
||||
$result = $this->prepareData($tableName);
|
||||
$connectionShortName = null;
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
$reportTables->populateTable($tableName, $connectionShortName);
|
||||
$reportTables->populateTable($tableName);
|
||||
|
||||
$expected = $result->dataFields;
|
||||
$expected['APP_UID'] = $result->applicationUid;
|
||||
@@ -337,7 +336,7 @@ class ReportTablesTest extends TestCase
|
||||
$tableName = 'TestReportTable';
|
||||
$result = $this->prepareData($tableName);
|
||||
$connectionShortName = 'wf';
|
||||
$type = null;
|
||||
$type = '';
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
$reportTables->populateTable($tableName, $connectionShortName, $type);
|
||||
@@ -395,7 +394,7 @@ class ReportTablesTest extends TestCase
|
||||
$result = $this->prepareData($tableName);
|
||||
$connectionShortName = 'wf';
|
||||
$type = 'NORMAL';
|
||||
$fields = null;
|
||||
$fields = [];
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
$reportTables->populateTable($tableName, $connectionShortName, $type, $fields);
|
||||
@@ -453,7 +452,7 @@ class ReportTablesTest extends TestCase
|
||||
$result = $this->prepareData($tableName);
|
||||
$connectionShortName = 'wf';
|
||||
$type = 'NORMAL';
|
||||
$fields = "";
|
||||
$fields = [];
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
$reportTables->populateTable($tableName, $connectionShortName, $type, $fields);
|
||||
@@ -513,7 +512,7 @@ class ReportTablesTest extends TestCase
|
||||
$connectionShortName = 'wf';
|
||||
$type = 'NORMAL';
|
||||
$fields = $result->fields;
|
||||
$proUid = null;
|
||||
$proUid = '';
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
$reportTables->populateTable($tableName, $connectionShortName, $type, $fields, $proUid);
|
||||
@@ -575,7 +574,7 @@ class ReportTablesTest extends TestCase
|
||||
$type = 'NORMAL';
|
||||
$fields = $result->fields;
|
||||
$proUid = $result->processUid;
|
||||
$grid = null;
|
||||
$grid = '';
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
$reportTables->populateTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid);
|
||||
@@ -844,4 +843,92 @@ class ReportTablesTest extends TestCase
|
||||
$result = json_decode($data, JSON_OBJECT_AS_ARRAY);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers ReportTables::generateOldReportTable
|
||||
* @covers ReportTables::buildAndExecuteQuery
|
||||
* @covers ReportTables::buildFieldsSection
|
||||
* @covers ReportTables::buildValuesSection
|
||||
*/
|
||||
public function it_should_test_generateOldReportTable_for_normal()
|
||||
{
|
||||
$tableName = 'TestReportTable';
|
||||
$result = $this->prepareData($tableName);
|
||||
$connectionShortName = 'wf';
|
||||
$type = 'NORMAL';
|
||||
$fields = $result->fields;
|
||||
$proUid = $result->processUid;
|
||||
$grid = '';
|
||||
|
||||
$start = 0;
|
||||
$limit = 100;
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
DB::delete("TRUNCATE TABLE `{$tableName}` ");
|
||||
|
||||
$reportTables->generateOldReportTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid, $start, $limit);
|
||||
|
||||
$expected = $result->dataFields;
|
||||
$expected['APP_UID'] = $result->applicationUid;
|
||||
$expected['APP_NUMBER'] = $result->applicationNumber;
|
||||
|
||||
$actual = (array) DB::table($tableName)
|
||||
->select()
|
||||
->first();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers ReportTables::generateOldReportTable
|
||||
* @covers ReportTables::buildAndExecuteQuery
|
||||
* @covers ReportTables::buildFieldsSection
|
||||
* @covers ReportTables::buildValuesSection
|
||||
*/
|
||||
public function it_should_test_generateOldReportTable_for_grid()
|
||||
{
|
||||
$tableName = 'TestReportTable';
|
||||
$result = $this->prepareData($tableName, true);
|
||||
$connectionShortName = 'wf';
|
||||
$type = 'GRID';
|
||||
$fields = $result->fields;
|
||||
$proUid = $result->processUid;
|
||||
$grid = 'var_Grid1';
|
||||
|
||||
$app = Application::where('APP_UID', '=', $result->applicationUid)->get()->first();
|
||||
$appData = unserialize($app->APP_DATA);
|
||||
$appData['var_Textarea1'] = [];
|
||||
$appData = serialize($appData);
|
||||
Application::where('APP_UID', '=', $result->applicationUid)->update(['APP_DATA' => $appData]);
|
||||
|
||||
$start = 0;
|
||||
$limit = 100;
|
||||
|
||||
$reportTables = new ReportTables();
|
||||
DB::delete("TRUNCATE TABLE `{$tableName}` ");
|
||||
|
||||
$reportTables->generateOldReportTable($tableName, $connectionShortName, $type, $fields, $proUid, $grid, $start, $limit);
|
||||
|
||||
$indexRow = 1;
|
||||
$expected = $result->appData[$grid];
|
||||
foreach ($expected as &$row) {
|
||||
$row['APP_UID'] = $result->applicationUid;
|
||||
$row['APP_NUMBER'] = $result->applicationNumber;
|
||||
$row['ROW'] = (string) ($indexRow++);
|
||||
}
|
||||
$expected = array_values($expected);
|
||||
|
||||
$actual = DB::table($tableName)
|
||||
->select()
|
||||
->get();
|
||||
$actual->transform(function ($item, $key) {
|
||||
return (array) $item;
|
||||
});
|
||||
$actual = $actual->toArray();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use Faker\Factory;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use ProcessMaker\Model\AppThread;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
@@ -151,10 +152,25 @@ class WsBaseTest extends TestCase
|
||||
*/
|
||||
private function createTemplate($proUid, $usrUid)
|
||||
{
|
||||
if (!file_exists(PATH_DB)) {
|
||||
mkdir(PATH_DB);
|
||||
}
|
||||
if (!file_exists(PATH_DATA_SITE)) {
|
||||
mkdir(PATH_DATA_SITE);
|
||||
}
|
||||
$data = file_get_contents(PATH_TRUNK . 'tests/resources/template.html');
|
||||
if (!file_exists(PATH_DATA_SITE . 'mailTemplates')) {
|
||||
mkdir(PATH_DATA_SITE . 'mailTemplates');
|
||||
}
|
||||
file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . 'template.html', $data);
|
||||
if (!file_exists(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid)) {
|
||||
mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid);
|
||||
}
|
||||
file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data);
|
||||
$template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([
|
||||
'PRO_UID' => $proUid,
|
||||
'USR_UID' => $usrUid,
|
||||
'PRF_PATH' => '/'
|
||||
'PRF_PATH' => 'template.html'
|
||||
]);
|
||||
return $template;
|
||||
}
|
||||
@@ -996,11 +1012,24 @@ class WsBaseTest extends TestCase
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
|
||||
// Create the data related to the cancel a case
|
||||
$task = factory(Task::class)->create();
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_CREATE_USER' => $user->USR_UID
|
||||
]);
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_USER' => $user->USR_UID
|
||||
]);
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
factory(UserReporting::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID
|
||||
]);
|
||||
$application = factory(Application::class)->states('foreign_keys')->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
@@ -1018,6 +1047,7 @@ class WsBaseTest extends TestCase
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_PREVIOUS' => 2
|
||||
]);
|
||||
|
||||
$ws = new WsBase();
|
||||
@@ -1050,6 +1080,8 @@ class WsBaseTest extends TestCase
|
||||
]);
|
||||
$application = factory(Application::class)->states('foreign_keys')->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
// Create the first thread
|
||||
@@ -1067,6 +1099,7 @@ class WsBaseTest extends TestCase
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_PREVIOUS' => 2,
|
||||
]);
|
||||
// Create the second thread
|
||||
factory(AppThread::class)->create([
|
||||
@@ -1079,10 +1112,12 @@ class WsBaseTest extends TestCase
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'PRO_UID' => $application->PRO_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 3,
|
||||
'DEL_PREVIOUS' => 3,
|
||||
]);
|
||||
|
||||
$ws = new WsBase();
|
||||
@@ -1259,4 +1294,119 @@ class WsBaseTest extends TestCase
|
||||
//Assert the expected number of unassigned cases
|
||||
$this->assertCount(0, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required fields in pause case
|
||||
*
|
||||
* @covers WsBase::pauseCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_review_fields_to_pause_case()
|
||||
{
|
||||
// Validate the appUid
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase('', 0, '');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
// Validate the status
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($application->APP_UID, 0, '');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
// Validate the index
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($application->APP_UID, '', '');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
// Validate the user
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, '');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
// If needs to validate the current user
|
||||
$user = factory(User::class)->create();
|
||||
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $user->USR_UID, null, true);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
// Validate if status is closed
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
// Validate if the case is paused
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
factory(AppDelay::class)->create([
|
||||
'APP_DELEGATION_USER' => $delegation->USR_UID,
|
||||
'PRO_UID' => $delegation->PRO_UID,
|
||||
'APP_NUMBER' => $delegation->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'APP_THREAD_INDEX' => 1,
|
||||
'APP_THREAD_PARENT' => 0,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null);
|
||||
// Review the unpaused date
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, '06/13/2019 5:35 PM');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required fields in pause case
|
||||
*
|
||||
* @covers WsBase::pauseCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_pause_case()
|
||||
{
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
factory(AppDelay::class)->create([
|
||||
'APP_DELEGATION_USER' => $delegation->USR_UID,
|
||||
'PRO_UID' => $delegation->PRO_UID,
|
||||
'APP_NUMBER' => $delegation->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'APP_THREAD_INDEX' => 1,
|
||||
'APP_THREAD_PARENT' => 0,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID);
|
||||
$this->assertEquals($response->status_code, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,11 @@ class OutputDocumentTest extends TestCase
|
||||
$properties['margins']['right'] = 15;
|
||||
$properties['margins']['top'] = 15;
|
||||
$properties['margins']['bottom'] = 15;
|
||||
$properties['pdfSecurity'] = true;
|
||||
$properties['pdfSecurity'] = [
|
||||
'openPassword' => true,
|
||||
'ownerPassword' => true,
|
||||
'permissions' => 'r'
|
||||
];
|
||||
// Call output document
|
||||
$outputDocument = new OutputDocument();
|
||||
$outputDocument->generateTcpdf(
|
||||
|
||||
@@ -799,6 +799,7 @@ class PmTablesProxyTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_varchar_id_exception()
|
||||
{
|
||||
$this->markTestSkipped("Is not compatible with php74.");
|
||||
$reportTable = new ReportTable();
|
||||
|
||||
//PM table with a varchar id
|
||||
@@ -976,6 +977,7 @@ class PmTablesProxyTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_destroy_method()
|
||||
{
|
||||
$this->markTestSkipped("Is not compatible with php74.");
|
||||
$obj = new pmTablesProxy();
|
||||
|
||||
//Variable that is sent to the destroy method
|
||||
@@ -998,6 +1000,7 @@ class PmTablesProxyTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_destroy_method_success()
|
||||
{
|
||||
$this->markTestSkipped("Is not compatible with php74.");
|
||||
$reportTable = new ReportTable();
|
||||
|
||||
//PM table with a varchar id
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\methods\cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
class ProxyNewCasesListTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* This sets the initial parameters for each test.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
$this->settingUserLogged();
|
||||
}
|
||||
|
||||
/**
|
||||
* This starts a valid user in session with the appropriate permissions.
|
||||
* @global object $RBAC
|
||||
*/
|
||||
private function settingUserLogged()
|
||||
{
|
||||
global $RBAC;
|
||||
|
||||
$user = User::where('USR_ID', '=', 1)
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result contains an error
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_there_is_an_error_in_the_proxy_new_cases_list_file()
|
||||
{
|
||||
//Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
//Call the tested file
|
||||
require_once PATH_METHODS . 'cases/proxyNewCasesList.php';
|
||||
|
||||
//Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
//Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
// This asserts there is an error in the output
|
||||
$this->assertEquals('{"error":"ID_ACCESS_DENIED"}', $outputBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result contains an empty "search" field
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_response_of_the_proxy_new_cases_list_file()
|
||||
{
|
||||
$_REQUEST["paged"] = '';
|
||||
$_REQUEST['count'] = '';
|
||||
$_REQUEST["category"] = '';
|
||||
$_REQUEST["process"] = '';
|
||||
$_REQUEST["search"] = 'fsfaefwa';
|
||||
$_REQUEST["filter"] = '';
|
||||
$_REQUEST["dateFrom"] = '';
|
||||
$_REQUEST["dateTo"] = '';
|
||||
$_REQUEST["start"] = '';
|
||||
$_REQUEST["limit"] = '';
|
||||
$_REQUEST['sort'] = 'ASC';
|
||||
$_REQUEST["dir"] = '';
|
||||
$_REQUEST["action"] = 'todo';
|
||||
$_REQUEST["user"] = '';
|
||||
$_REQUEST["list"] = 'inbox';
|
||||
$_REQUEST["filterStatus"] = '';
|
||||
$_REQUEST['openApplicationUid'] = '';
|
||||
|
||||
//Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
//Call the tested file
|
||||
require_once PATH_METHODS . 'cases/proxyNewCasesList.php';
|
||||
|
||||
//Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
|
||||
//Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
$result = json_decode($outputBuffer, true);
|
||||
|
||||
//This asserts that the search parameter has an empty value
|
||||
$this->assertEmpty($result['filters']['search']);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class DraftTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
Application::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,8 @@ class ParticipatedTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
Application::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ class UnassignedTest extends TestCase
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
Groupwf::truncate();
|
||||
Application::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace ProcessMaker\BusinessModel;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\Variable;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\Fields;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessVariables;
|
||||
use Tests\TestCase;
|
||||
@@ -16,7 +18,6 @@ use Tests\TestCase;
|
||||
*/
|
||||
class VariableTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test it create variables related to the process
|
||||
*
|
||||
@@ -272,4 +273,30 @@ class VariableTest extends TestCase
|
||||
$variable = new Variable();
|
||||
$result = $variable->executeSqlControl(null, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* This verify the exception
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Variable::throwExceptionIfVariableIsAssociatedAditionalTable()
|
||||
*/
|
||||
public function it_should_test_exception_when_a_variable_is_related_table()
|
||||
{
|
||||
//assert
|
||||
$this->expectException(Exception::class);
|
||||
// Create process variable
|
||||
$variable = factory(ProcessVariables::class)->create();
|
||||
$result = ProcessVariables::getVariable($variable->VAR_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
// Create tables
|
||||
$table = factory(AdditionalTables::class)->create([
|
||||
'PRO_UID' => $variable->PRO_UID,
|
||||
]);
|
||||
// Create fields
|
||||
$fields = factory(Fields::class)->create([
|
||||
'ADD_TAB_UID' => $table->ADD_TAB_UID,
|
||||
'FLD_NAME' => $variable->VAR_NAME,
|
||||
]);
|
||||
$variable = new Variable();
|
||||
$res = $variable->throwExceptionIfVariableIsAssociatedAditionalTable($variable->VAR_UID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,31 @@ class AdditionalTablesTest extends TestCase
|
||||
$this->assertCount(1, $table->offline([$table->ADD_TAB_OFFLINE])->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope query to get the offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::scopeProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_process()
|
||||
{
|
||||
$table = factory(AdditionalTables::class)->create();
|
||||
$this->assertCount(1, $table->process($table->PRO_UID)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope query to get tables related to the process
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::getTables()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_tables_related_to_process()
|
||||
{
|
||||
$table = factory(AdditionalTables::class)->create();
|
||||
$result = AdditionalTables::getTables($table->PRO_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get the structure of offline tables
|
||||
*
|
||||
|
||||
@@ -11,6 +11,7 @@ use ProcessMaker\Model\AppAssignSelfServiceValue;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppThread;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\GroupUser;
|
||||
use ProcessMaker\Model\Groupwf;
|
||||
@@ -37,8 +38,9 @@ class DelegationTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Application::truncate();
|
||||
Delegation::truncate();
|
||||
AppThread::truncate();
|
||||
Application::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,4 +42,19 @@ class FieldsTest extends TestCase
|
||||
$result = Fields::getFields($fields->ADD_TAB_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope and search a field related to the specific ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Fields::scopeField()
|
||||
* @covers \ProcessMaker\Model\Fields::scopeFieldOrLabel()
|
||||
* @covers \ProcessMaker\Model\Fields::searchVariable()
|
||||
* @test
|
||||
*/
|
||||
public function it_search_field()
|
||||
{
|
||||
$fields = factory(Fields::class)->create();
|
||||
$result = Fields::searchVariable($fields->ADD_TAB_UID, $fields->FLD_NAME);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,19 @@ class ProcessVariablesTest extends TestCase
|
||||
$this->assertEquals($process[0]['PRO_UID'], $result[1]['PRJ_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test it return a variable related to the VAR_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\ProcessVariables::getVariable()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_variable()
|
||||
{
|
||||
$table = factory(ProcessVariables::class)->create();
|
||||
$result = ProcessVariables::getVariable($table->VAR_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test it return the variables related to the PRO_ID
|
||||
*
|
||||
@@ -76,6 +89,8 @@ class ProcessVariablesTest extends TestCase
|
||||
/**
|
||||
* Test it return the variables by type related to the PRO_ID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\ProcessVariables::scopeProcessId()
|
||||
* @covers \ProcessMaker\Model\ProcessVariables::scopeTypeId()
|
||||
* @covers \ProcessMaker\Model\ProcessVariables::getVariablesByType()
|
||||
* @test
|
||||
*/
|
||||
|
||||
@@ -113,7 +113,7 @@ class CasesTest extends TestCase
|
||||
$rest = $this->initializeRestApi($user->USR_UID);
|
||||
$rest->apiMethodInfo->methodName = 'doGetCaseVariables';
|
||||
$rest->apiMethodInfo->arguments = [
|
||||
'app_uid' => 0,
|
||||
'appUid' => 0,
|
||||
'dyn_uid' => 1,
|
||||
'app_index' => 2
|
||||
];
|
||||
@@ -156,7 +156,7 @@ class CasesTest extends TestCase
|
||||
$rest = $this->initializeRestApi($user->USR_UID);
|
||||
$rest->apiMethodInfo->methodName = 'doGetCaseVariables';
|
||||
$rest->apiMethodInfo->arguments = [
|
||||
'app_uid' => 0,
|
||||
'appUid' => 0,
|
||||
'dyn_uid' => 1,
|
||||
'app_index' => 2
|
||||
];
|
||||
@@ -199,7 +199,7 @@ class CasesTest extends TestCase
|
||||
$rest = $this->initializeRestApi(RBAC::GUEST_USER_UID);
|
||||
$rest->apiMethodInfo->methodName = 'doGetCaseVariables';
|
||||
$rest->apiMethodInfo->arguments = [
|
||||
'app_uid' => 0,
|
||||
'appUid' => 0,
|
||||
'dyn_uid' => 1,
|
||||
'app_index' => 2
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user