PMC-1412
This commit is contained in:
@@ -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();
|
||||||
|
|
||||||
|
// This asserts there is an error in the output
|
||||||
|
$this->assertEquals('{"error":"ID_ACCESS_DENIED"}', $outputBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
$result = json_decode($outputBuffer, true);
|
||||||
|
|
||||||
|
//This asserts that the search parameter has an empty value
|
||||||
|
$this->assertEmpty($result['filters']['search']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -191,6 +191,7 @@ try {
|
|||||||
$response['filters'] = $filters;
|
$response['filters'] = $filters;
|
||||||
$response['totalCount'] = $list->getCountList($userUid, $filters);
|
$response['totalCount'] = $list->getCountList($userUid, $filters);
|
||||||
$response['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($result);
|
$response['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($result);
|
||||||
|
!empty($response['filters']['search']) ? $response['filters']['search'] = '' : '';
|
||||||
echo G::json_encode($response);
|
echo G::json_encode($response);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$msg = array("error" => $e->getMessage());
|
$msg = array("error" => $e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user