PMCORE-3918

This commit is contained in:
Paula Quispe
2022-08-12 13:39:32 -04:00
parent 76548d59e3
commit 17a4dd112a
2 changed files with 324 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
<?php
namespace Tests\unit\workflow\engine\methods\cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\User;
use RBAC;
use Tests\TestCase;
class ProxyNewCasesListTest extends TestCase
{
use DatabaseTransactions;
/**
* This sets the initial parameters for each test.
*/
public function setUp()
{
parent::setUp(); // TODO: Change the autogenerated stub
$this->settingUserLogged();
}
/**
* This starts a valid user in session with the appropriate permissions.
* @global object $RBAC
*/
private function settingUserLogged()
{
global $RBAC;
$user = User::where('USR_ID', '=', 1)
->get()
->first();
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->initRBAC();
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
}
/**
* It tests the result contains an error
*
* @test
*/
public function it_should_test_there_is_an_error_in_the_proxy_new_cases_list_file()
{
// Turn on output buffering
ob_start();
// Call the tested file
require_once PATH_METHODS . 'cases/proxyNewCasesList.php';
// Return the contents of the output buffer
$outputBuffer = ob_get_contents();
// Clean the output buffer and turn off output buffering
ob_end_clean();
// Parse JSON
$result = json_decode($outputBuffer, true);
// This asserts there is an error in the output
$this->assertNotEmpty($result);
$this->assertArrayHasKey('error', $result);
}
/**
* It tests the result contains an empty "search" field
*
* @test
*/
public function it_should_test_the_response_of_the_proxy_new_cases_list_file()
{
$_REQUEST["paged"] = '';
$_REQUEST['count'] = '';
$_REQUEST["category"] = '';
$_REQUEST["process"] = '';
$_REQUEST["search"] = 'fsfaefwa';
$_REQUEST["filter"] = '';
$_REQUEST["dateFrom"] = '';
$_REQUEST["dateTo"] = '';
$_REQUEST["start"] = '';
$_REQUEST["limit"] = '';
$_REQUEST['sort'] = 'ASC';
$_REQUEST["dir"] = '';
$_REQUEST["action"] = 'todo';
$_REQUEST["user"] = '';
$_REQUEST["list"] = 'inbox';
$_REQUEST["filterStatus"] = '';
$_REQUEST['openApplicationUid'] = '';
// Turn on output buffering
ob_start();
// Call the tested file
require_once PATH_METHODS . 'cases/proxyNewCasesList.php';
// Return the contents of the output buffer
$outputBuffer = ob_get_contents();
// Clean the output buffer and turn off output buffering
ob_end_clean();
// Parse JSON
$result = json_decode($outputBuffer, true);
// This asserts that the search parameter has an empty value
if (!empty($result)) {
$this->assertArrayHasKey('search', $result);
} else {
$this->assertNull($result);
}
}
}