PMCORE-1138
This commit is contained in:
14
database/factories/BpmnDiagramFactory.php
Normal file
14
database/factories/BpmnDiagramFactory.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\BpmnDiagram::class, function(Faker $faker) {
|
||||
return [
|
||||
'DIA_UID' => $faker->regexify("/[a-zA-Z]{32}/"),
|
||||
'PRJ_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\BpmnProject::class)->create()->PRJ_UID;
|
||||
},
|
||||
'DIA_NAME' => $faker->name,
|
||||
'DIA_IS_CLOSABLE' => 0,
|
||||
];
|
||||
});
|
||||
32
database/factories/BpmnEventFactory.php
Normal file
32
database/factories/BpmnEventFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\BpmnEvent::class, function(Faker $faker) {
|
||||
$bpmnProcess = factory(\ProcessMaker\Model\BpmnProcess::class)->create();
|
||||
return [
|
||||
'EVN_UID' => $faker->regexify("/[a-zA-Z]{32}/"),
|
||||
'PRJ_UID' => $bpmnProcess->PRJ_UID,
|
||||
'PRO_UID' => $bpmnProcess->PRO_UID,
|
||||
'EVN_NAME' => $faker->name,
|
||||
'EVN_TYPE' => 'START',
|
||||
'EVN_MARKER' => 'EMPTY',
|
||||
'EVN_IS_INTERRUPTING' => 1,
|
||||
'EVN_ATTACHED_TO' => '',
|
||||
'EVN_CANCEL_ACTIVITY' => 0,
|
||||
'EVN_ACTIVITY_REF' => null,
|
||||
'EVN_WAIT_FOR_COMPLETION' => 0,
|
||||
'EVN_ERROR_NAME' => null,
|
||||
'EVN_ERROR_CODE' => null,
|
||||
'EVN_ESCALATION_NAME' => null,
|
||||
'EVN_ESCALATION_CODE' => null,
|
||||
'EVN_CONDITION' => null,
|
||||
'EVN_MESSAGE' => '',
|
||||
'EVN_OPERATION_NAME' => null,
|
||||
'EVN_OPERATION_IMPLEMENTATION_REF' => null,
|
||||
'EVN_TIME_DATE' => null,
|
||||
'EVN_TIME_CYCLE' => null,
|
||||
'EVN_TIME_DURATION' => null,
|
||||
'EVN_BEHAVIOR' => 'THROW',
|
||||
];
|
||||
});
|
||||
20
database/factories/BpmnProcessFactory.php
Normal file
20
database/factories/BpmnProcessFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\BpmnProcess::class, function(Faker $faker) {
|
||||
return [
|
||||
'PRO_UID' => $faker->regexify("/[a-zA-Z]{32}/"),
|
||||
'PRJ_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\BpmnProject::class)->create()->PRJ_UID;
|
||||
},
|
||||
'DIA_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\BpmnDiagram::class)->create()->DIA_UID;
|
||||
},
|
||||
'PRO_NAME' => $faker->title,
|
||||
'PRO_TYPE' => 'NONE',
|
||||
'PRO_IS_EXECUTABLE' => 0,
|
||||
'PRO_IS_CLOSED' => 0,
|
||||
'PRO_IS_SUBPROCESS' => 0,
|
||||
];
|
||||
});
|
||||
21
database/factories/EmailEventFactory.php
Normal file
21
database/factories/EmailEventFactory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\EmailEvent::class, function(Faker $faker) {
|
||||
$bpmnEvent = factory(\ProcessMaker\Model\BpmnEvent::class)->create();
|
||||
return [
|
||||
'EMAIL_EVENT_UID' => $faker->regexify("/[a-zA-Z]{32}/"),
|
||||
'PRJ_UID' => $bpmnEvent->PRJ_UID,
|
||||
'EVN_UID' => $bpmnEvent->EVN_UID,
|
||||
'EMAIL_EVENT_FROM' => $faker->email,
|
||||
'EMAIL_EVENT_TO' => $faker->email,
|
||||
'EMAIL_EVENT_SUBJECT' => $faker->title,
|
||||
'PRF_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\ProcessFiles::class)->create()->PRF_UID;
|
||||
},
|
||||
'EMAIL_SERVER_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\EmailServerModel::class)->create()->MESS_UID;
|
||||
},
|
||||
];
|
||||
});
|
||||
@@ -8,7 +8,7 @@ $factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
||||
// Return with default values
|
||||
return [
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 200000),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 1000000),
|
||||
'PRO_TITLE' => $faker->sentence(3),
|
||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||
@@ -28,7 +28,7 @@ $factory->state(\ProcessMaker\Model\Process::class, 'foreign_keys', function (Fa
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
return [
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 200000),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 1000000),
|
||||
'PRO_TITLE' => $faker->sentence(3),
|
||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||
'PRO_CREATE_USER' => $user->USR_UID,
|
||||
@@ -49,7 +49,7 @@ $factory->state(\ProcessMaker\Model\Process::class, 'flow', function (Faker $fak
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = [
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 200000),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 1000000),
|
||||
'PRO_TITLE' => $faker->sentence(3),
|
||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||
'PRO_CREATE_USER' => $user->USR_UID,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Jobs\EmailEvent;
|
||||
use Faker\Factory;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppThread;
|
||||
@@ -13,8 +14,15 @@ use ProcessMaker\Model\User;
|
||||
use ProcessMaker\Util\WsMessageResponse;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class WsBase
|
||||
*
|
||||
* @coversDefaultClass WsBase
|
||||
*/
|
||||
class WsBaseTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Constructor of the class.
|
||||
*
|
||||
@@ -207,9 +215,10 @@ class WsBaseTest extends TestCase
|
||||
/**
|
||||
* This should send an email of types elements to the work queue jobs.
|
||||
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
||||
{
|
||||
@@ -246,9 +255,10 @@ class WsBaseTest extends TestCase
|
||||
/**
|
||||
* This should send an email of types elements without work queue jobs.
|
||||
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
||||
{
|
||||
@@ -284,9 +294,10 @@ class WsBaseTest extends TestCase
|
||||
|
||||
/**
|
||||
* It should send an sendMessage with queue jobs and empty config parameter.
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||
{
|
||||
@@ -322,9 +333,10 @@ class WsBaseTest extends TestCase
|
||||
|
||||
/**
|
||||
* It should send an sendMessage without queue jobs and empty config parameter.
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||
{
|
||||
@@ -360,9 +372,10 @@ class WsBaseTest extends TestCase
|
||||
|
||||
/**
|
||||
* It should send an sendMessage with queue jobs and config parameter like id.
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||
{
|
||||
@@ -398,9 +411,10 @@ class WsBaseTest extends TestCase
|
||||
|
||||
/**
|
||||
* It should send an sendMessage without queue jobs and config parameter like id.
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||
{
|
||||
@@ -436,9 +450,10 @@ class WsBaseTest extends TestCase
|
||||
|
||||
/**
|
||||
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
||||
*
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers \WsBase::sendMessage
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
||||
{
|
||||
@@ -476,7 +491,7 @@ class WsBaseTest extends TestCase
|
||||
* Test that the casesList method returns the case title value
|
||||
*
|
||||
* @test
|
||||
* @covers \WsBase::caseList
|
||||
* @covers WsBase::caseList()
|
||||
*/
|
||||
public function it_should_test_that_the_cases_list_method_returns_the_case_title()
|
||||
{
|
||||
@@ -550,7 +565,7 @@ class WsBaseTest extends TestCase
|
||||
* Test the casesList method when the result is empty
|
||||
*
|
||||
* @test
|
||||
* @covers \WsBase::caseList
|
||||
* @covers WsBase::caseList()
|
||||
*/
|
||||
public function it_should_test_the_cases_list_method_when_there_are_no_results()
|
||||
{
|
||||
@@ -617,7 +632,7 @@ class WsBaseTest extends TestCase
|
||||
/**
|
||||
* This test ensures obtaining the email configuration with all fields.
|
||||
* @test
|
||||
* @covers \WsBase::sendMessage()
|
||||
* @covers WsBase::sendMessage()
|
||||
*/
|
||||
public function it_should_get_email_configuration()
|
||||
{
|
||||
@@ -645,4 +660,287 @@ class WsBaseTest extends TestCase
|
||||
//assertions
|
||||
$this->assertInstanceOf(WsMessageResponse::class, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review if the flag is true when the cancel case is related to the same case in SESSION
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_set_flag_when_is_same_case()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$_SESSION["APPLICATION"] = $delegation->APP_UID;
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->APP_UID);
|
||||
$this->assertEquals($ws->getFlagSameCase(), true);
|
||||
$this->assertNotEmpty($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required field caseUid
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_validate_required_app_uid()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase('', $delegation->DE_INDEX, $delegation->URS_UID);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' caseUid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required field status = TO_DO
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_validate_required_status_todo()
|
||||
{
|
||||
// Create a case in DRAFT status
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 1,
|
||||
'APP_STATUS' => 'DRAFT'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' DRAFT');
|
||||
|
||||
// Create a case in COMPLETED status
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 3,
|
||||
'APP_STATUS' => 'COMPLETED'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' COMPLETED');
|
||||
|
||||
// Create a case in CANCELLED status
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 4,
|
||||
'APP_STATUS' => 'CANCELLED'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' CANCELLED');
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required field delIndex
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_validate_required_del_index()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, '', $delegation->USR_UID);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' delIndex');
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required field open thread
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_validate_required_open_thread()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED'
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, '');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_DELEGATION_ALREADY_CLOSED"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the required field userUid
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_validate_required_usr_uid()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, '');
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' userUid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Review cancel case with parallel threads
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_validate_only_one_thread_opened()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_THREAD_INDEX' => 1,
|
||||
'APP_THREAD_PARENT' => 1,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_THREAD_INDEX' => 2,
|
||||
'APP_THREAD_PARENT' => 1,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
$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,
|
||||
]);
|
||||
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID);
|
||||
$this->assertEquals($response->status_code, 100);
|
||||
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_CANCELLED_PARALLEL"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the cancel case with one thread open
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_cancel_case()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_THREAD_INDEX' => 1,
|
||||
'APP_THREAD_PARENT' => 1,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
$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,
|
||||
]);
|
||||
|
||||
$ws = new WsBase();
|
||||
// todo: the action Case::cancelCase() use Propel queries
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID);
|
||||
$this->assertNotEmpty($response);
|
||||
$this->markTestIncomplete(
|
||||
'This test was not fully implemented.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the cancel case with parallel threads
|
||||
*
|
||||
* @covers WsBase::cancelCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_cancel_case_parallel()
|
||||
{
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_THREAD_INDEX' => 1,
|
||||
'APP_THREAD_PARENT' => 1,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN'
|
||||
]);
|
||||
factory(AppThread::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_THREAD_INDEX' => 2,
|
||||
'APP_THREAD_PARENT' => 1,
|
||||
'APP_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
$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,
|
||||
]);
|
||||
|
||||
$ws = new WsBase();
|
||||
// todo: the action Case::cancelCase() use Propel queries
|
||||
$response = (object)$ws->cancelCase($delegation->APP_UID, null, null);
|
||||
$this->assertNotEmpty($response);
|
||||
// Stop here and mark this test as incomplete.
|
||||
$this->markTestIncomplete(
|
||||
'This test was not fully implemented.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,4 +250,101 @@ class EmailServerTest extends TestCase
|
||||
$this->expectException(Exception::class);
|
||||
$actual = $this->emailServer->getEmailServer($emailServerUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the sendTestMail method with a successful result
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\EmailServer::sendTestMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_send_test_mail_method()
|
||||
{
|
||||
// The data that will be sent to the method
|
||||
$data = [
|
||||
"FROM_EMAIL" => "admin@processmaker.com",
|
||||
"FROM_NAME" => "Administrator",
|
||||
"MESS_ENGINE" => "MAIL",
|
||||
"MESS_SERVER" => "localhost",
|
||||
"MESS_PORT" => 25,
|
||||
"MESS_ACCOUNT" => "admin@processmaker.com",
|
||||
"MESS_PASSWORD" => "",
|
||||
"TO" => "admin@processmaker.com",
|
||||
"MESS_RAUTH" => true
|
||||
];
|
||||
|
||||
// Create the EmailServer object
|
||||
$emailServer = new EmailServer();
|
||||
// Call the sendTestMail method
|
||||
$result = $emailServer->sendTestMail($data);
|
||||
|
||||
// Assert the status is true
|
||||
$this->assertTrue($result['status']);
|
||||
// Assert the success is true
|
||||
$this->assertTrue($result['success']);
|
||||
// Assert the message of the result
|
||||
$this->assertEquals('**ID_MAIL_TEST_SUCCESS**', $result['msg']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the sendTestMail method with a failed result
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\EmailServer::sendTestMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_send_test_mail_method_failure()
|
||||
{
|
||||
// The data that will be sent to the method
|
||||
$data = [
|
||||
"FROM_EMAIL" => "admin@processmaker.com",
|
||||
"FROM_NAME" => "Administrator",
|
||||
"MESS_ENGINE" => "PHPMAILER",
|
||||
"MESS_SERVER" => "smtp.gmail.com",
|
||||
"MESS_PORT" => 587,
|
||||
"MESS_ACCOUNT" => "admin@processmaker.com",
|
||||
"MESS_PASSWORD" => "",
|
||||
"TO" => "admin@processmaker.com",
|
||||
"MESS_RAUTH" => false,
|
||||
];
|
||||
|
||||
// Create the EmailServer object
|
||||
$emailServer = new EmailServer();
|
||||
// Call the sendTestMail method
|
||||
$result = $emailServer->sendTestMail($data);
|
||||
|
||||
// Assert the status is false
|
||||
$this->assertFalse($result['status']);
|
||||
// Assert the status is false
|
||||
$this->assertFalse($result['success']);
|
||||
// Assert the message of the result is empty
|
||||
$this->assertEmpty($result['msg']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the sendTestMail method with an exception
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\EmailServer::sendTestMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_send_test_mail_method_exception()
|
||||
{
|
||||
// The data that will be sent to the method
|
||||
$data = [];
|
||||
|
||||
// Create the EmailServer object
|
||||
$emailServer = new EmailServer();
|
||||
|
||||
// This expects an exception message
|
||||
$this->expectExceptionMessage("Undefined index: MESS_ENGINE");
|
||||
|
||||
// Call the sendTestMail method
|
||||
$emailServer->sendTestMail($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the tearDown method
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Exception;
|
||||
use Faker\Factory;
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\FilesManager;
|
||||
use ProcessMaker\Model\EmailEvent as EmailEventModel;
|
||||
use ProcessMaker\Model\Process as ProcessModel;
|
||||
use ProcessMaker\Model\ProcessFiles as ProcessFilesModel;
|
||||
use ProcessMaker\Model\User as UserModel;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FilesManagerTest extends TestCase
|
||||
{
|
||||
private $faker;
|
||||
private $directories;
|
||||
|
||||
/**
|
||||
* Set up method.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->faker = Factory::create();
|
||||
$this->directories = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down method.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->directories = array_reverse($this->directories);
|
||||
foreach ($this->directories as $value) {
|
||||
rmdir($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verifies if a file is missing.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\FilesManager::deleteProcessFilesManager()
|
||||
*/
|
||||
public function it_should_deleted_public_files_when_not_exist()
|
||||
{
|
||||
$proUid = G::generateUniqueID();
|
||||
$prfUid = G::generateUniqueID();
|
||||
$filesManager = new FilesManager();
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$filesManager->deleteProcessFilesManager($proUid, $prfUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* This represents the windows and linux separators.
|
||||
*/
|
||||
public function directorySeparator()
|
||||
{
|
||||
return [
|
||||
["linux", "/"],
|
||||
["windows", "\\"]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verifies the deletion of a template.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\FilesManager::deleteProcessFilesManager()
|
||||
* @dataProvider directorySeparator
|
||||
*/
|
||||
public function it_should_deleted_a_template_file($type, $separator)
|
||||
{
|
||||
$user = factory(UserModel::class)->create([
|
||||
'USR_UID' => G::generateUniqueID()
|
||||
]);
|
||||
|
||||
$process = factory(ProcessModel::class)->create([
|
||||
'PRO_UID' => G::generateUniqueID()
|
||||
]);
|
||||
|
||||
//create a template file
|
||||
$directory = PATH_DATA_SITE;
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
$directory = PATH_DATA_PUBLIC;
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
$directory = PATH_DATA_PUBLIC . $process->PRO_UID;
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
$fileName = "template1.html";
|
||||
$path = $directory . "/" . $fileName;
|
||||
file_put_contents($path, $this->faker->randomHtml());
|
||||
|
||||
$processFiles = factory(ProcessFilesModel::class)->create([
|
||||
'PRF_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'PRF_PATH' => $separator . $fileName
|
||||
]);
|
||||
|
||||
$filesManager = new FilesManager();
|
||||
$filesManager->deleteProcessFilesManager($process->PRO_UID, $processFiles->PRF_UID);
|
||||
|
||||
//assert empty registry
|
||||
$expectedEmptyObject = ProcessFilesModel::where('PRF_UID', '=', $processFiles->PRF_UID)->first();
|
||||
$this->assertTrue(empty($expectedEmptyObject));
|
||||
|
||||
//assert empty file
|
||||
$this->assertTrue(!file_exists($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verifies the deletion of a public file.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\FilesManager::deleteProcessFilesManager()
|
||||
* @dataProvider directorySeparator
|
||||
*/
|
||||
public function it_should_deleted_a_public_file($type, $separator)
|
||||
{
|
||||
$user = factory(UserModel::class)->create([
|
||||
'USR_UID' => G::generateUniqueID()
|
||||
]);
|
||||
|
||||
$process = factory(ProcessModel::class)->create([
|
||||
'PRO_UID' => G::generateUniqueID()
|
||||
]);
|
||||
|
||||
//create a temporal file
|
||||
$directory = PATH_DATA_SITE;
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
$directory = PATH_DATA_MAILTEMPLATES;
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
$directory = PATH_DATA_MAILTEMPLATES . $process->PRO_UID;
|
||||
if (!is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
$fileName = "temporal.html";
|
||||
$path = $directory . "/" . $fileName;
|
||||
file_put_contents($path, $this->faker->randomHtml());
|
||||
|
||||
$processFiles = factory(ProcessFilesModel::class)->create([
|
||||
'PRF_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'PRF_PATH' => $separator . $fileName
|
||||
]);
|
||||
|
||||
$filesManager = new FilesManager();
|
||||
$filesManager->deleteProcessFilesManager($process->PRO_UID, $processFiles->PRF_UID);
|
||||
|
||||
//assert empty registry
|
||||
$expectedEmptyObject = ProcessFilesModel::where('PRF_UID', '=', $processFiles->PRF_UID)->first();
|
||||
$this->assertTrue(empty($expectedEmptyObject));
|
||||
|
||||
//assert empty file
|
||||
$this->assertTrue(!file_exists($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* This test verifies the removal of a template that is being used by an
|
||||
* intermediate email event.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\FilesManager::deleteProcessFilesManager()
|
||||
*/
|
||||
public function it_should_deleted_public_files_with_event_relation()
|
||||
{
|
||||
$user = factory(UserModel::class)->create([
|
||||
'USR_UID' => G::generateUniqueID()
|
||||
]);
|
||||
|
||||
$process = factory(ProcessModel::class)->create([
|
||||
'PRO_UID' => G::generateUniqueID()
|
||||
]);
|
||||
|
||||
$processFiles = factory(ProcessFilesModel::class)->create([
|
||||
'PRF_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'PRF_PATH' => '/'
|
||||
]);
|
||||
|
||||
$emailEvent = factory(EmailEventModel::class)->create([
|
||||
'PRF_UID' => $processFiles->PRF_UID
|
||||
]);
|
||||
|
||||
$filesManager = new FilesManager();
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$filesManager->deleteProcessFilesManager($process->PRO_UID, $processFiles->PRF_UID);
|
||||
}
|
||||
}
|
||||
@@ -928,70 +928,6 @@ class DelegationTest extends TestCase
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service and self-service value based
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::countSelfService()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self service
|
||||
factory(Delegation::class, 15)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create a task self service value based
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task1->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self service value based
|
||||
factory(Delegation::class, 15)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(30, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service group assigned
|
||||
*
|
||||
@@ -1095,6 +1031,83 @@ class DelegationTest extends TestCase
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly with self-service and self-service-value-based
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::countSelfService()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_and_self_service_value_based()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
//Create a task self service
|
||||
$taskSelfService = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $taskSelfService->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self service
|
||||
factory(Delegation::class)->create([
|
||||
'TAS_ID' => $taskSelfService->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
|
||||
//Create a task self service value based
|
||||
$taskSelfServiceByVariable = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $taskSelfServiceByVariable->TAS_UID,
|
||||
'USR_UID' => $group->GRP_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appAssignSelfService->ID,
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self service value based
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $appAssignSelfService->APP_NUMBER,
|
||||
'DEL_INDEX' => $appAssignSelfService->DEL_INDEX,
|
||||
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(2, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service user and group assigned in parallel task
|
||||
*
|
||||
|
||||
@@ -546,45 +546,36 @@ class Ajax
|
||||
G::RenderPage('publish', 'extJs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel case from actions menu
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.3/Cases/Actions#Cancel
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cancelCase()
|
||||
{
|
||||
$oCase = new Cases();
|
||||
$multiple = false;
|
||||
|
||||
if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) {
|
||||
$APP_UID = $_POST['APP_UID'];
|
||||
$DEL_INDEX = $_POST['DEL_INDEX'];
|
||||
|
||||
$appUids = explode(',', $APP_UID);
|
||||
$delIndexes = explode(',', $DEL_INDEX);
|
||||
if (count($appUids) > 1 && count($delIndexes) > 1) {
|
||||
$multiple = true;
|
||||
try {
|
||||
$appUid = !empty($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : '';
|
||||
$index = !empty($_SESSION['INDEX']) ? $_SESSION['INDEX'] : '';
|
||||
$usrUid = !empty($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '';
|
||||
$result = new stdclass();
|
||||
if (!empty($appUid) && !empty($index) && !empty($usrUid)) {
|
||||
$ws = new WsBase();
|
||||
$response = (object)$ws->cancelCase($appUid, $index, $usrUid);
|
||||
// Review if the case was cancelled, true if the case was cancelled
|
||||
$result->status = ($response->status_code == 0) ? true : false;
|
||||
$result->msg = $response->message;
|
||||
} else {
|
||||
$result->status = false;
|
||||
$result->msg = G::LoadTranslation("ID_CASE_USER_INVALID_CANCEL_CASE", [$usrUid]);
|
||||
}
|
||||
} elseif (isset($_POST['sApplicationUID']) && isset($_POST['iIndex'])) {
|
||||
$APP_UID = $_POST['sApplicationUID'];
|
||||
$DEL_INDEX = $_POST['iIndex'];
|
||||
} else {
|
||||
$APP_UID = $_SESSION['APPLICATION'];
|
||||
$DEL_INDEX = $_SESSION['INDEX'];
|
||||
} catch (Exception $e) {
|
||||
$result->status = false;
|
||||
$result->msg = $e->getMessage();
|
||||
}
|
||||
|
||||
// Save the note pause reason
|
||||
if ($_POST['NOTE_REASON'] != '') {
|
||||
require_once("classes/model/AppNotes.php");
|
||||
$appNotes = new AppNotes();
|
||||
$noteContent = addslashes($_POST['NOTE_REASON']);
|
||||
$appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE']);
|
||||
}
|
||||
// End save
|
||||
|
||||
|
||||
if ($multiple) {
|
||||
foreach ($appUids as $i => $appUid) {
|
||||
$oCase->cancelCase($appUid, $delIndexes[$i], $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
} else {
|
||||
$oCase->cancelCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
print G::json_encode($result);
|
||||
}
|
||||
|
||||
public function getUsersToReassign()
|
||||
|
||||
@@ -311,9 +311,8 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
//close tab only if IE11
|
||||
|
||||
if ($isIE && !isset($_SESSION['__OUTLOOK_CONNECTOR__'])) {
|
||||
//close tab only if IE11 add a validation was added if the current skin is uxs
|
||||
if ($isIE && !isset($_SESSION['__OUTLOOK_CONNECTOR__']) && SYS_SKIN !== "uxs") {
|
||||
$script = "<script type='text/javascript'>
|
||||
try {
|
||||
if(top.opener) {
|
||||
|
||||
@@ -195,7 +195,7 @@ class EmailServer
|
||||
$bodyPre = new TemplatePower(PATH_TPL . "admin" . PATH_SEP . "email.tpl");
|
||||
|
||||
$bodyPre->prepare();
|
||||
$bodyPre->assign("server", $_SERVER["SERVER_NAME"]);
|
||||
$bodyPre->assign("server", System::getServerProtocol() . System::getServerHost());
|
||||
$bodyPre->assign("date", date("H:i:s"));
|
||||
$bodyPre->assign("ver", System::getVersion());
|
||||
$bodyPre->assign("engine", $engine);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use EmailEventPeer;
|
||||
use Exception;
|
||||
use G;
|
||||
use Criteria;
|
||||
use ProcessFiles;
|
||||
use ProcessFilesPeer;
|
||||
use ProcessPeer;
|
||||
use ResultSet;
|
||||
use TaskPeer;
|
||||
|
||||
class FilesManager
|
||||
@@ -671,62 +673,60 @@ class FilesManager
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* Deletes the physical file and its corresponding record in the database.
|
||||
* @param string $proUid {@min 32} {@max 32}
|
||||
* @param string $prfUid {@min 32} {@max 32}
|
||||
*
|
||||
*
|
||||
* @param bool $verifyingRelationship
|
||||
* @access public
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteProcessFilesManager($sProcessUID, $prfUid, $verifyingRelationship = false)
|
||||
public function deleteProcessFilesManager($proUid, $prfUid, $verifyingRelationship = false)
|
||||
{
|
||||
try {
|
||||
$path = '';
|
||||
$criteriaPf = new \Criteria("workflow");
|
||||
$criteriaPf->addSelectColumn(\ProcessFilesPeer::PRF_PATH);
|
||||
$criteriaPf->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteriaPf);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
while ($aRow = $rsCriteria->getRow()) {
|
||||
$path = $aRow['PRF_PATH'];
|
||||
$rsCriteria->next();
|
||||
$criteriaProcessFiles = new Criteria("workflow");
|
||||
$criteriaProcessFiles->addSelectColumn(ProcessFilesPeer::PRF_PATH);
|
||||
$criteriaProcessFiles->add(ProcessFilesPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
||||
$resultSet1 = ProcessFilesPeer::doSelectRS($criteriaProcessFiles);
|
||||
$resultSet1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$resultSet1->next();
|
||||
while ($row = $resultSet1->getRow()) {
|
||||
$path = $row['PRF_PATH'];
|
||||
$resultSet1->next();
|
||||
}
|
||||
if ($path == '') {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid')));
|
||||
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid')));
|
||||
}
|
||||
|
||||
$relationshipEmailEvent = false;
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\EmailEventPeer::PRF_UID);
|
||||
$criteria->add(\EmailEventPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
while ($aRow = $rsCriteria->getRow()) {
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->addSelectColumn(EmailEventPeer::PRF_UID);
|
||||
$criteria->add(EmailEventPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
||||
$resultSet2 = EmailEventPeer::doSelectRS($criteria);
|
||||
$resultSet2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$resultSet2->next();
|
||||
while ($row = $resultSet2->getRow()) {
|
||||
$relationshipEmailEvent = true;
|
||||
$rsCriteria->next();
|
||||
$resultSet2->next();
|
||||
}
|
||||
$explodePath = explode(DIRECTORY_SEPARATOR,$path);
|
||||
|
||||
$path = str_replace("\\", "/", $path);
|
||||
$fileName = basename($path);
|
||||
if ($relationshipEmailEvent && !$verifyingRelationship) {
|
||||
throw new \Exception(\G::LoadTranslation(G::LoadTranslation('ID_CANNOT_REMOVE_TEMPLATE_EMAIL_EVENT',
|
||||
[end($explodePath)])));
|
||||
throw new Exception(G::LoadTranslation(G::LoadTranslation('ID_CANNOT_REMOVE_TEMPLATE_EMAIL_EVENT', [$fileName])));
|
||||
}
|
||||
|
||||
$sFile = end($explodePath);
|
||||
$path = PATH_DATA_MAILTEMPLATES.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
|
||||
|
||||
$path = PATH_DATA_MAILTEMPLATES . $proUid . "/" . $fileName;
|
||||
if (file_exists($path) && !is_dir($path)) {
|
||||
unlink($path);
|
||||
} else {
|
||||
$path = PATH_DATA_PUBLIC.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
|
||||
|
||||
if (file_exists($path) && !is_dir($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$path = PATH_DATA_PUBLIC . $proUid . "/" . $fileName;
|
||||
if (file_exists($path) && !is_dir($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
$rs = \ProcessFilesPeer::doDelete($criteriaPf);
|
||||
ProcessFilesPeer::doDelete($criteriaProcessFiles);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
13
workflow/engine/src/ProcessMaker/Model/BpmnDiagram.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/BpmnDiagram.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BpmnDiagram extends Model
|
||||
{
|
||||
protected $table = 'BPMN_DIAGRAM';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
13
workflow/engine/src/ProcessMaker/Model/BpmnEvent.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/BpmnEvent.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BpmnEvent extends Model
|
||||
{
|
||||
protected $table = 'BPMN_EVENT';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
13
workflow/engine/src/ProcessMaker/Model/BpmnProcess.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/BpmnProcess.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BpmnProcess extends Model
|
||||
{
|
||||
protected $table = 'BPMN_PROCESS';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@@ -9,6 +9,8 @@ class BpmnProject extends Model
|
||||
// Set our table name
|
||||
protected $table = 'BPMN_PROJECT';
|
||||
protected $primaryKey = 'PRJ_UID';
|
||||
public $incrementing = false;
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
workflow/engine/src/ProcessMaker/Model/EmailEvent.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/EmailEvent.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EmailEvent extends Model
|
||||
{
|
||||
protected $table = 'EMAIL_EVENT';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ class ProcessFiles extends Model
|
||||
{
|
||||
protected $table = 'PROCESS_FILES';
|
||||
protected $primaryKey = 'PRF_UID';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<img id='logo' src='http://{server}/images/processmaker.logo.jpg' />
|
||||
<img id='logo' src='{server}/images/processmaker.logo.jpg' />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1026,81 +1026,86 @@ Ext.onReady(function(){
|
||||
});
|
||||
}
|
||||
|
||||
Actions.cancelCase = function()
|
||||
{
|
||||
var msgCancel = new Ext.Window({
|
||||
width:500,
|
||||
plain: true,
|
||||
modal: true,
|
||||
resizable: false,
|
||||
title: _('ID_CONFIRM'),
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
labelAlign: 'top',
|
||||
labelWidth: 75,
|
||||
border: false,
|
||||
frame: true,
|
||||
Actions.cancelCase = function () {
|
||||
var msgCancel = new Ext.Window({
|
||||
width: 500,
|
||||
plain: true,
|
||||
modal: true,
|
||||
resizable: false,
|
||||
title: _('ID_CONFIRM'),
|
||||
items: [
|
||||
{
|
||||
html: '<div align="center" style="font: 14px tahoma,arial,helvetica,sans-serif">' + _('ID_CONFIRM_CANCEL_CASE')+'? </div> <br/>'
|
||||
},
|
||||
{
|
||||
xtype: 'textarea',
|
||||
id: 'noteReason',
|
||||
fieldLabel: _('ID_CASE_CANCEL_REASON'),
|
||||
name: 'noteReason',
|
||||
width: 450,
|
||||
height: 50
|
||||
},
|
||||
{
|
||||
id: 'notifyReason',
|
||||
xtype:'checkbox',
|
||||
name: 'notifyReason',
|
||||
hideLabel: true,
|
||||
boxLabel: _('ID_NOTIFY_USERS_CASE')
|
||||
}
|
||||
],
|
||||
|
||||
buttonAlign: 'center',
|
||||
|
||||
buttons: [{
|
||||
text: 'Ok',
|
||||
handler: function(){
|
||||
if (Ext.getCmp('noteReason').getValue() != '') {
|
||||
var noteReasonTxt = _('ID_CASE_CANCEL_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
|
||||
} else {
|
||||
var noteReasonTxt = '';
|
||||
}
|
||||
var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0;
|
||||
|
||||
Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} });
|
||||
Ext.Ajax.request({
|
||||
url : 'ajaxListener' ,
|
||||
params : {action : 'cancelCase', NOTE_REASON: noteReasonTxt, NOTIFY_PAUSE: notifyReasonVal},
|
||||
success: function ( result, request ) {
|
||||
try {
|
||||
parent.notify("", _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM)));
|
||||
parent.updateCasesTree();
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
location.href = 'casesListExtJs';
|
||||
},
|
||||
failure: function ( result, request) {
|
||||
Ext.MessageBox.alert( _('ID_FAILED'), result.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
},{
|
||||
text: _('ID_CANCEL'),
|
||||
handler: function(){
|
||||
msgCancel.close();
|
||||
}
|
||||
}]
|
||||
})
|
||||
]
|
||||
});
|
||||
msgCancel.show(this);
|
||||
new Ext.FormPanel({
|
||||
labelAlign: 'top',
|
||||
labelWidth: 75,
|
||||
border: false,
|
||||
frame: true,
|
||||
items: [{
|
||||
html: '<div align="center" style="font: 14px tahoma,arial,helvetica,sans-serif">' + _('ID_CONFIRM_CANCEL_CASE') + '? </div> <br/>'
|
||||
},
|
||||
{
|
||||
xtype: 'textarea',
|
||||
id: 'noteReason',
|
||||
fieldLabel: _('ID_CASE_CANCEL_REASON'),
|
||||
name: 'noteReason',
|
||||
width: 450,
|
||||
height: 50
|
||||
},
|
||||
{
|
||||
id: 'notifyReason',
|
||||
xtype: 'checkbox',
|
||||
name: 'notifyReason',
|
||||
hideLabel: true,
|
||||
boxLabel: _('ID_NOTIFY_USERS_CASE')
|
||||
}],
|
||||
buttonAlign: 'center',
|
||||
buttons: [{
|
||||
text: 'Ok',
|
||||
handler: function () {
|
||||
if (Ext.getCmp('noteReason').getValue() != '') {
|
||||
var noteReasonTxt = _('ID_CASE_CANCEL_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
|
||||
} else {
|
||||
var noteReasonTxt = '';
|
||||
}
|
||||
var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0;
|
||||
Ext.MessageBox.show({msg: _('ID_PROCESSING'), wait: true, waitConfig: {interval: 200}});
|
||||
Ext.Ajax.request({
|
||||
url: 'ajaxListener',
|
||||
params: {
|
||||
action: 'cancelCase',
|
||||
NOTE_REASON: noteReasonTxt,
|
||||
NOTIFY_PAUSE: notifyReasonVal
|
||||
},
|
||||
success: function (result, request) {
|
||||
try {
|
||||
var data = Ext.util.JSON.decode(result.responseText);
|
||||
if (data.status == true) {
|
||||
// The case was cancelled
|
||||
parent.notify('', _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM)));
|
||||
} else {
|
||||
// The case wasn't cancel
|
||||
parent.notify('', data.msg);
|
||||
}
|
||||
parent.updateCasesTree();
|
||||
} catch (e) {
|
||||
parent.notify('', _('ID_SOMETHING_WRONG'));
|
||||
}
|
||||
location.href = 'casesListExtJs';
|
||||
},
|
||||
failure: function (result, request) {
|
||||
Ext.MessageBox.alert(_('ID_FAILED'), result.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: _('ID_CANCEL'),
|
||||
handler: function () {
|
||||
msgCancel.close();
|
||||
}
|
||||
}]
|
||||
})
|
||||
]
|
||||
});
|
||||
msgCancel.show(this);
|
||||
}
|
||||
|
||||
Actions.getUsersToReassign = function()
|
||||
|
||||
Reference in New Issue
Block a user