PMCORE-490

This commit is contained in:
Paula Quispe
2020-01-06 14:30:41 -04:00
parent 8c4c329abe
commit 26bde68123
12 changed files with 278 additions and 79 deletions

View File

@@ -0,0 +1,80 @@
<?php
namespace ProcessMaker\BusinessModel;
use Exception;
use G;
use ProcessMaker\Model\Application;
use RBAC;
use Tests\TestCase;
/**
* Class DelegationTest
*
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases
*/
class CasesTest extends TestCase
{
/**
* This checks the delete case
*
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
* @test
* @expectedException Exception
*/
public function it_should_not_delete_case_without_permission()
{
// Set the RBAC
global $RBAC;
$_SESSION['USER_LOGGED'] = '00000000000000000000000000000002';
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->initRBAC();
$application = factory(Application::class)->create();
// Tried to delete case
$case = new Cases();
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
}
/**
* This checks the delete case
*
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
* @test
* @expectedException Exception
*/
public function it_should_not_delete_case_in_todo_status()
{
// Set the RBAC
global $RBAC;
$_SESSION['USER_LOGGED'] = '00000000000000000000000000000001';
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->initRBAC();
$application = factory(Application::class)->create(['APP_STATUS' => 'TO_DO']);
// Tried to delete case
$case = new Cases();
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
}
/**
* This checks the delete case
*
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
* @test
* @expectedException Exception
*/
public function it_should_not_delete_case_when_is_not_owner()
{
// Set the RBAC
global $RBAC;
$_SESSION['USER_LOGGED'] = '00000000000000000000000000000001';
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->initRBAC();
$application = factory(Application::class)->create(['APP_INIT_USER' => '00000000000000000000000000000002']);
// Tried to delete case
$case = new Cases();
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
}
}