370 lines
13 KiB
PHP
370 lines
13 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\unit\workflow\engine\classes;
|
||
|
|
|
||
|
|
use Cases;
|
||
|
|
use ProcessMaker\Model\Application;
|
||
|
|
use ProcessMaker\Model\Delegation;
|
||
|
|
use ProcessMaker\Model\Process;
|
||
|
|
use ProcessMaker\Model\Step;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class CasesTest extends TestCase
|
||
|
|
{
|
||
|
|
protected $preserveGlobalState = false;
|
||
|
|
protected $runTestInSeparateProcess = true;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Call setUp method
|
||
|
|
*/
|
||
|
|
public function setUp()
|
||
|
|
{
|
||
|
|
parent::setUp(); // TODO: Change the autogenerated stub
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test getNextStep method with no steps
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX);
|
||
|
|
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method with step
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_position()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '1 == 1'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method with output document
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_output_document()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '1 == 1',
|
||
|
|
'STEP_TYPE_OBJ' => 'OUTPUT_DOCUMENT'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method with input document
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_input_document()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '1 == 1',
|
||
|
|
'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method with external document
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_external()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '1 == 1',
|
||
|
|
'STEP_TYPE_OBJ' => 'EXTERNAL'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method with message step
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_message()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '1 == 1',
|
||
|
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method when the step does not exist
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_step_does_not_exists()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$this->expectExceptionMessage("**ID_STEP_DOES_NOT_EXIST**");
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method when there is an exception
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_step_exception()
|
||
|
|
{
|
||
|
|
$cases = new Cases();
|
||
|
|
$this->expectExceptionMessage("The Application row '' doesn't exist!");
|
||
|
|
$res = $cases->getNextStep();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method when the result is false
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_step_false()
|
||
|
|
{
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create();
|
||
|
|
$appDelegation = factory(Delegation::class)->create();
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX);
|
||
|
|
$this->assertFalse($res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method when there is a gmail account
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_gmail()
|
||
|
|
{
|
||
|
|
$_SESSION['gmail'] = '';
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '1 == 1',
|
||
|
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method when there is a gmail account related to the next step
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_gmail_nextstep()
|
||
|
|
{
|
||
|
|
$_SESSION['gmail'] = '';
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 1,
|
||
|
|
'STEP_CONDITION' => '1 == 1',
|
||
|
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests the getNextStep method when the step condition is empty
|
||
|
|
*
|
||
|
|
* @covers \Cases::getNextStep()
|
||
|
|
* @test
|
||
|
|
*/
|
||
|
|
public function it_should_test_get_next_step_method_condition_empty()
|
||
|
|
{
|
||
|
|
$_SESSION['gmail'] = '';
|
||
|
|
$process = factory(Process::class)->create();
|
||
|
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||
|
|
$appDelegation = factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID
|
||
|
|
]);
|
||
|
|
factory(Delegation::class)->create([
|
||
|
|
'APP_UID' => $application->APP_UID,
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'DEL_INDEX' => 2,
|
||
|
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||
|
|
]);
|
||
|
|
factory(Step::class)->create([
|
||
|
|
'PRO_UID' => $process->PRO_UID,
|
||
|
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||
|
|
'STEP_POSITION' => 2,
|
||
|
|
'STEP_CONDITION' => '',
|
||
|
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||
|
|
]);
|
||
|
|
$cases = new Cases();
|
||
|
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||
|
|
$this->assertCount(4, $res);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Call the tearDown method
|
||
|
|
*/
|
||
|
|
public function tearDown()
|
||
|
|
{
|
||
|
|
// The parent method needs to be override due to errors appearing
|
||
|
|
}
|
||
|
|
}
|