Merged in bugfix/PMCORE-543 (pull request #7238)
PMCORE-543 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -8,7 +8,7 @@ $factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
|||||||
// Return with default values
|
// Return with default values
|
||||||
return [
|
return [
|
||||||
'PRO_UID' => G::generateUniqueID(),
|
'PRO_UID' => G::generateUniqueID(),
|
||||||
'PRO_ID' => $faker->unique()->numberBetween(1, 200000),
|
'PRO_ID' => $faker->unique()->numberBetween(1, 1000000),
|
||||||
'PRO_TITLE' => $faker->sentence(3),
|
'PRO_TITLE' => $faker->sentence(3),
|
||||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||||
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
'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();
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
return [
|
return [
|
||||||
'PRO_UID' => G::generateUniqueID(),
|
'PRO_UID' => G::generateUniqueID(),
|
||||||
'PRO_ID' => $faker->unique()->numberBetween(1, 200000),
|
'PRO_ID' => $faker->unique()->numberBetween(1, 1000000),
|
||||||
'PRO_TITLE' => $faker->sentence(3),
|
'PRO_TITLE' => $faker->sentence(3),
|
||||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||||
'PRO_CREATE_USER' => $user->USR_UID,
|
'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();
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
$process = [
|
$process = [
|
||||||
'PRO_UID' => G::generateUniqueID(),
|
'PRO_UID' => G::generateUniqueID(),
|
||||||
'PRO_ID' => $faker->unique()->numberBetween(1, 200000),
|
'PRO_ID' => $faker->unique()->numberBetween(1, 1000000),
|
||||||
'PRO_TITLE' => $faker->sentence(3),
|
'PRO_TITLE' => $faker->sentence(3),
|
||||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||||
'PRO_CREATE_USER' => $user->USR_UID,
|
'PRO_CREATE_USER' => $user->USR_UID,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\Jobs\EmailEvent;
|
use App\Jobs\EmailEvent;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\Queue;
|
use Illuminate\Support\Facades\Queue;
|
||||||
use ProcessMaker\Model\Application;
|
use ProcessMaker\Model\Application;
|
||||||
use ProcessMaker\Model\AppThread;
|
use ProcessMaker\Model\AppThread;
|
||||||
@@ -13,8 +14,15 @@ use ProcessMaker\Model\User;
|
|||||||
use ProcessMaker\Util\WsMessageResponse;
|
use ProcessMaker\Util\WsMessageResponse;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class WsBase
|
||||||
|
*
|
||||||
|
* @coversDefaultClass WsBase
|
||||||
|
*/
|
||||||
class WsBaseTest extends TestCase
|
class WsBaseTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of the class.
|
* 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.
|
* 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
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithQueue
|
* @dataProvider messageTypesWithQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
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.
|
* 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
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
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.
|
* It should send an sendMessage with queue jobs and empty config parameter.
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithQueue
|
* @dataProvider messageTypesWithQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
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.
|
* It should send an sendMessage without queue jobs and empty config parameter.
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
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.
|
* It should send an sendMessage with queue jobs and config parameter like id.
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithQueue
|
* @dataProvider messageTypesWithQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
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.
|
* It should send an sendMessage without queue jobs and config parameter like id.
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
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.
|
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
||||||
|
*
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers \WsBase::sendMessage
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
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 that the casesList method returns the case title value
|
||||||
*
|
*
|
||||||
* @test
|
* @test
|
||||||
* @covers \WsBase::caseList
|
* @covers WsBase::caseList()
|
||||||
*/
|
*/
|
||||||
public function it_should_test_that_the_cases_list_method_returns_the_case_title()
|
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 the casesList method when the result is empty
|
||||||
*
|
*
|
||||||
* @test
|
* @test
|
||||||
* @covers \WsBase::caseList
|
* @covers WsBase::caseList()
|
||||||
*/
|
*/
|
||||||
public function it_should_test_the_cases_list_method_when_there_are_no_results()
|
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.
|
* This test ensures obtaining the email configuration with all fields.
|
||||||
* @test
|
* @test
|
||||||
* @covers \WsBase::sendMessage()
|
* @covers WsBase::sendMessage()
|
||||||
*/
|
*/
|
||||||
public function it_should_get_email_configuration()
|
public function it_should_get_email_configuration()
|
||||||
{
|
{
|
||||||
@@ -645,4 +660,287 @@ class WsBaseTest extends TestCase
|
|||||||
//assertions
|
//assertions
|
||||||
$this->assertInstanceOf(WsMessageResponse::class, $result);
|
$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.'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,45 +546,36 @@ class Ajax
|
|||||||
G::RenderPage('publish', 'extJs');
|
G::RenderPage('publish', 'extJs');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel case from actions menu
|
||||||
|
*
|
||||||
|
* @link https://wiki.processmaker.com/3.3/Cases/Actions#Cancel
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function cancelCase()
|
public function cancelCase()
|
||||||
{
|
{
|
||||||
$oCase = new Cases();
|
try {
|
||||||
$multiple = false;
|
$appUid = !empty($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : '';
|
||||||
|
$index = !empty($_SESSION['INDEX']) ? $_SESSION['INDEX'] : '';
|
||||||
if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) {
|
$usrUid = !empty($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '';
|
||||||
$APP_UID = $_POST['APP_UID'];
|
$result = new stdclass();
|
||||||
$DEL_INDEX = $_POST['DEL_INDEX'];
|
if (!empty($appUid) && !empty($index) && !empty($usrUid)) {
|
||||||
|
$ws = new WsBase();
|
||||||
$appUids = explode(',', $APP_UID);
|
$response = (object)$ws->cancelCase($appUid, $index, $usrUid);
|
||||||
$delIndexes = explode(',', $DEL_INDEX);
|
// Review if the case was cancelled, true if the case was cancelled
|
||||||
if (count($appUids) > 1 && count($delIndexes) > 1) {
|
$result->status = ($response->status_code == 0) ? true : false;
|
||||||
$multiple = true;
|
$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'])) {
|
} catch (Exception $e) {
|
||||||
$APP_UID = $_POST['sApplicationUID'];
|
$result->status = false;
|
||||||
$DEL_INDEX = $_POST['iIndex'];
|
$result->msg = $e->getMessage();
|
||||||
} else {
|
|
||||||
$APP_UID = $_SESSION['APPLICATION'];
|
|
||||||
$DEL_INDEX = $_SESSION['INDEX'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the note pause reason
|
print G::json_encode($result);
|
||||||
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']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsersToReassign()
|
public function getUsersToReassign()
|
||||||
|
|||||||
@@ -1026,81 +1026,86 @@ Ext.onReady(function(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Actions.cancelCase = function()
|
Actions.cancelCase = function () {
|
||||||
{
|
var msgCancel = new Ext.Window({
|
||||||
var msgCancel = new Ext.Window({
|
width: 500,
|
||||||
width:500,
|
plain: true,
|
||||||
plain: true,
|
modal: true,
|
||||||
modal: true,
|
resizable: false,
|
||||||
resizable: false,
|
title: _('ID_CONFIRM'),
|
||||||
title: _('ID_CONFIRM'),
|
|
||||||
items: [
|
|
||||||
new Ext.FormPanel({
|
|
||||||
labelAlign: 'top',
|
|
||||||
labelWidth: 75,
|
|
||||||
border: false,
|
|
||||||
frame: true,
|
|
||||||
items: [
|
items: [
|
||||||
{
|
new Ext.FormPanel({
|
||||||
html: '<div align="center" style="font: 14px tahoma,arial,helvetica,sans-serif">' + _('ID_CONFIRM_CANCEL_CASE')+'? </div> <br/>'
|
labelAlign: 'top',
|
||||||
},
|
labelWidth: 75,
|
||||||
{
|
border: false,
|
||||||
xtype: 'textarea',
|
frame: true,
|
||||||
id: 'noteReason',
|
items: [{
|
||||||
fieldLabel: _('ID_CASE_CANCEL_REASON'),
|
html: '<div align="center" style="font: 14px tahoma,arial,helvetica,sans-serif">' + _('ID_CONFIRM_CANCEL_CASE') + '? </div> <br/>'
|
||||||
name: 'noteReason',
|
},
|
||||||
width: 450,
|
{
|
||||||
height: 50
|
xtype: 'textarea',
|
||||||
},
|
id: 'noteReason',
|
||||||
{
|
fieldLabel: _('ID_CASE_CANCEL_REASON'),
|
||||||
id: 'notifyReason',
|
name: 'noteReason',
|
||||||
xtype:'checkbox',
|
width: 450,
|
||||||
name: 'notifyReason',
|
height: 50
|
||||||
hideLabel: true,
|
},
|
||||||
boxLabel: _('ID_NOTIFY_USERS_CASE')
|
{
|
||||||
}
|
id: 'notifyReason',
|
||||||
],
|
xtype: 'checkbox',
|
||||||
|
name: 'notifyReason',
|
||||||
buttonAlign: 'center',
|
hideLabel: true,
|
||||||
|
boxLabel: _('ID_NOTIFY_USERS_CASE')
|
||||||
buttons: [{
|
}],
|
||||||
text: 'Ok',
|
buttonAlign: 'center',
|
||||||
handler: function(){
|
buttons: [{
|
||||||
if (Ext.getCmp('noteReason').getValue() != '') {
|
text: 'Ok',
|
||||||
var noteReasonTxt = _('ID_CASE_CANCEL_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
|
handler: function () {
|
||||||
} else {
|
if (Ext.getCmp('noteReason').getValue() != '') {
|
||||||
var noteReasonTxt = '';
|
var noteReasonTxt = _('ID_CASE_CANCEL_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
|
||||||
}
|
} else {
|
||||||
var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0;
|
var noteReasonTxt = '';
|
||||||
|
}
|
||||||
Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} });
|
var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0;
|
||||||
Ext.Ajax.request({
|
Ext.MessageBox.show({msg: _('ID_PROCESSING'), wait: true, waitConfig: {interval: 200}});
|
||||||
url : 'ajaxListener' ,
|
Ext.Ajax.request({
|
||||||
params : {action : 'cancelCase', NOTE_REASON: noteReasonTxt, NOTIFY_PAUSE: notifyReasonVal},
|
url: 'ajaxListener',
|
||||||
success: function ( result, request ) {
|
params: {
|
||||||
try {
|
action: 'cancelCase',
|
||||||
parent.notify("", _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM)));
|
NOTE_REASON: noteReasonTxt,
|
||||||
parent.updateCasesTree();
|
NOTIFY_PAUSE: notifyReasonVal
|
||||||
}
|
},
|
||||||
catch (e) {
|
success: function (result, request) {
|
||||||
}
|
try {
|
||||||
location.href = 'casesListExtJs';
|
var data = Ext.util.JSON.decode(result.responseText);
|
||||||
},
|
if (data.status == true) {
|
||||||
failure: function ( result, request) {
|
// The case was cancelled
|
||||||
Ext.MessageBox.alert( _('ID_FAILED'), result.responseText);
|
parent.notify('', _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM)));
|
||||||
}
|
} else {
|
||||||
});
|
// The case wasn't cancel
|
||||||
}
|
parent.notify('', data.msg);
|
||||||
},{
|
}
|
||||||
text: _('ID_CANCEL'),
|
parent.updateCasesTree();
|
||||||
handler: function(){
|
} catch (e) {
|
||||||
msgCancel.close();
|
parent.notify('', _('ID_SOMETHING_WRONG'));
|
||||||
}
|
}
|
||||||
}]
|
location.href = 'casesListExtJs';
|
||||||
})
|
},
|
||||||
]
|
failure: function (result, request) {
|
||||||
});
|
Ext.MessageBox.alert(_('ID_FAILED'), result.responseText);
|
||||||
msgCancel.show(this);
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
text: _('ID_CANCEL'),
|
||||||
|
handler: function () {
|
||||||
|
msgCancel.close();
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
msgCancel.show(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Actions.getUsersToReassign = function()
|
Actions.getUsersToReassign = function()
|
||||||
|
|||||||
Reference in New Issue
Block a user