diff --git a/tests/unit/workflow/engine/methods/cases/ProxyNewCasesListTest.php b/tests/unit/workflow/engine/methods/cases/ProxyNewCasesListTest.php new file mode 100644 index 000000000..4be998640 --- /dev/null +++ b/tests/unit/workflow/engine/methods/cases/ProxyNewCasesListTest.php @@ -0,0 +1,107 @@ +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']); + } +} \ No newline at end of file diff --git a/workflow/engine/methods/cases/proxyNewCasesList.php b/workflow/engine/methods/cases/proxyNewCasesList.php index 43e620f7f..fb8221c01 100644 --- a/workflow/engine/methods/cases/proxyNewCasesList.php +++ b/workflow/engine/methods/cases/proxyNewCasesList.php @@ -191,6 +191,7 @@ try { $response['filters'] = $filters; $response['totalCount'] = $list->getCountList($userUid, $filters); $response['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($result); + !empty($response['filters']['search']) ? $response['filters']['search'] = '' : ''; echo G::json_encode($response); } catch (Exception $e) { $msg = array("error" => $e->getMessage());