2021-12-14 17:37:04 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
|
use ProcessMaker\Model\AppAssignSelfServiceValue;
|
|
|
|
|
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
|
|
|
|
|
use ProcessMaker\Model\Delegation;
|
|
|
|
|
use ProcessMaker\Model\GroupUser;
|
|
|
|
|
use ProcessMaker\Model\Groupwf;
|
|
|
|
|
use ProcessMaker\Model\RbacUsers;
|
|
|
|
|
use ProcessMaker\Model\Task;
|
|
|
|
|
use ProcessMaker\Model\User;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class AppAssignSelfServiceValueTest
|
|
|
|
|
*
|
|
|
|
|
* @coversDefaultClass \ProcessMaker\Model\AppAssignSelfServiceValue
|
|
|
|
|
*/
|
|
|
|
|
class AppAssignSelfServiceValueTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test belongs to APP_NUMBER
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::appNumber()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_belong_app_number()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$table = AppAssignSelfServiceValue::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'APP_NUMBER' => function () {
|
2022-07-21 00:04:21 -04:00
|
|
|
return Delegation::factory()->create()->APP_NUMBER;
|
2021-12-14 17:37:04 -04:00
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
$this->assertInstanceOf(Delegation::class, $table->appNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test belongs to DEL_INDEX
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::index()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_belong_index()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$table = AppAssignSelfServiceValue::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'DEL_INDEX' => function () {
|
2022-07-21 00:04:21 -04:00
|
|
|
return Delegation::factory()->create()->DEL_INDEX;
|
2021-12-14 17:37:04 -04:00
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
$this->assertInstanceOf(Delegation::class, $table->index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test belongs to TAS_ID
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::task()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_belong_task()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$table = AppAssignSelfServiceValue::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'TAS_ID' => function () {
|
2022-07-21 00:04:21 -04:00
|
|
|
return Task::factory()->create()->TAS_ID;
|
2021-12-14 17:37:04 -04:00
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
$this->assertInstanceOf(Task::class, $table->task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It tests getSelfServiceCasesByEvaluatePerUser()
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_self_service_by_value()
|
|
|
|
|
{
|
|
|
|
|
// Assign user in a group
|
2022-07-21 00:04:21 -04:00
|
|
|
$rbacUser = RbacUsers::factory()->create();
|
|
|
|
|
$user = User::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'USR_UID' => $rbacUser['USR_UID']
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$group = Groupwf::factory()->create();
|
|
|
|
|
$table = GroupUser::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'GRP_UID' => $group['GRP_UID'],
|
|
|
|
|
'GRP_ID' => $group['GRP_ID'],
|
|
|
|
|
'USR_UID' => $user['USR_UID'],
|
|
|
|
|
'USR_ID' => $user['USR_ID'],
|
|
|
|
|
]);
|
|
|
|
|
// Create the selfservice
|
2022-07-21 00:04:21 -04:00
|
|
|
$self = AppAssignSelfServiceValue::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'GRP_UID' => $group['GRP_UID'],
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$table = AppAssignSelfServiceValueGroup::factory()->create([
|
2021-12-14 17:37:04 -04:00
|
|
|
'ID' => $self['ID'],
|
|
|
|
|
'GRP_UID' => $group['GRP_UID'],
|
|
|
|
|
'ASSIGNEE_ID' => $group['GRP_ID'],
|
|
|
|
|
'ASSIGNEE_TYPE' => 2,
|
|
|
|
|
]);
|
|
|
|
|
$result = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($user['USR_UID']);
|
|
|
|
|
$this->assertNotEmpty($result);
|
|
|
|
|
}
|
|
|
|
|
}
|