Merged in bugfix/PMCORE-1124 (pull request #7245)
PMCORE-1124 Approved-by: Mauricio Veliz <mauricio@processmaker.com>
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\methods\cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\TaskUser;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CasesMenuHighlightTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* This sets the initial parameters for each test.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->settingUserLogged();
|
||||
}
|
||||
|
||||
/**
|
||||
* This starts a valid user in session with the appropriate permissions.
|
||||
*
|
||||
* @global object $RBAC
|
||||
*/
|
||||
private function settingUserLogged()
|
||||
{
|
||||
global $RBAC;
|
||||
|
||||
$this->user = User::where('USR_ID', '=', 1)->get()->first();
|
||||
|
||||
$_SESSION['USER_LOGGED'] = $this->user['USR_UID'];
|
||||
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the file is returning a valid JSON object with the correct data for the current user
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_response_of_the_cases_menu_highlight_file()
|
||||
{
|
||||
// Create process
|
||||
$process = factory(Process::class)->create();
|
||||
|
||||
// Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
|
||||
// Assign the current user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $this->user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
|
||||
// Create records in delegation relate to self-service
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0
|
||||
]);
|
||||
|
||||
// Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
// Call the tested file
|
||||
require_once PATH_METHODS . 'cases/casesMenuHighlight.php';
|
||||
|
||||
// Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
|
||||
// Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
// Check if is a valid JSON
|
||||
$this->assertJson($outputBuffer);
|
||||
|
||||
// Parse JSON
|
||||
$result = json_decode($outputBuffer, true);
|
||||
|
||||
// Check if the object is valid
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertArrayHasKey('item', $result[0]);
|
||||
$this->assertArrayHasKey('highlight', $result[0]);
|
||||
$this->assertEquals('CASES_SELFSERVICE', $result[0]['item']);
|
||||
$this->assertEquals(true, $result[0]['highlight']);
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,11 @@ class SystemTest extends TestCase
|
||||
$this->assertArrayHasKey('server_hostname_requests_frontend', $result);
|
||||
$this->assertArrayHasKey('disable_php_upload_execution', $result);
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
|
||||
// Default values for highlight home folder feature
|
||||
$this->assertArrayHasKey('highlight_home_folder_enable', $result);
|
||||
$this->assertArrayHasKey('highlight_home_folder_refresh_time', $result);
|
||||
$this->assertArrayHasKey('highlight_home_folder_scope', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +98,11 @@ class SystemTest extends TestCase
|
||||
$this->assertArrayHasKey('server_hostname_requests_frontend', $result);
|
||||
$this->assertArrayHasKey('disable_php_upload_execution', $result);
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
|
||||
// Default values for highlight home folder feature
|
||||
$this->assertArrayHasKey('highlight_home_folder_enable', $result);
|
||||
$this->assertArrayHasKey('highlight_home_folder_refresh_time', $result);
|
||||
$this->assertArrayHasKey('highlight_home_folder_scope', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,4 +181,60 @@ class SystemTest extends TestCase
|
||||
|
||||
$this->assertArrayHasKey("proxy_pass", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return parameters defined inside env file for "highlight home folders" feature.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_highlight_home_folders_params_defined_inside_env_file()
|
||||
{
|
||||
// Initializing variables to use
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
$faker = $faker = Factory::create();
|
||||
|
||||
// Get content of env.ini file, if exists
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
// Write correct values in env.ini file
|
||||
$highlightEnable = 1;
|
||||
$highlightRefreshTime = 5;
|
||||
$highlightScope = "unassigned";
|
||||
$content = "highlight_home_folder_enable = $highlightEnable" . PHP_EOL;
|
||||
$content .= "highlight_home_folder_refresh_time = $highlightRefreshTime" . PHP_EOL;
|
||||
$content .= "highlight_home_folder_scope = \"$highlightScope\"" . PHP_EOL;
|
||||
file_put_contents($path, $content);
|
||||
|
||||
// Get configuration
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
// Check correct parameters, should be the same
|
||||
$this->assertEquals($highlightEnable, $result["highlight_home_folder_enable"]);
|
||||
$this->assertEquals($highlightRefreshTime, $result["highlight_home_folder_refresh_time"]);
|
||||
$this->assertEquals($highlightScope, $result["highlight_home_folder_scope"]);
|
||||
|
||||
// Write incorrect values in env.ini file
|
||||
$highlightEnable = $faker->numberBetween(2, 100);
|
||||
$highlightRefreshTime = $faker->word;
|
||||
$highlightScope = $faker->word;
|
||||
$content = "highlight_home_folder_enable = $highlightEnable" . PHP_EOL;
|
||||
$content .= "highlight_home_folder_refresh_time = $highlightRefreshTime" . PHP_EOL;
|
||||
$content .= "highlight_home_folder_scope = \"$highlightScope\"" . PHP_EOL;
|
||||
file_put_contents($path, $content);
|
||||
|
||||
// Get configuration
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
// Check incorrect parameters, should be return the default values, the default values are private, so for the current
|
||||
// test has hardcoded values
|
||||
$this->assertEquals(0, $result["highlight_home_folder_enable"]);
|
||||
$this->assertEquals(10, $result["highlight_home_folder_refresh_time"]);
|
||||
$this->assertEquals("unassigned", $result["highlight_home_folder_scope"]);
|
||||
|
||||
// Restore content of th env.ini file
|
||||
file_put_contents($path, $oldContent);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -131,7 +131,6 @@ $oHeadPublisher->assign("FORMATS", $conf->getFormats());
|
||||
if (HIGHLIGHT_HOME_FOLDER_ENABLE) {
|
||||
$oHeadPublisher->assign("highlightUrlProxy", "casesMenuHighlight?r=");
|
||||
$oHeadPublisher->assign("highlightRefreshTime", HIGHLIGHT_HOME_FOLDER_REFRESH_TIME);
|
||||
$oHeadPublisher->assign("highlightScope", HIGHLIGHT_HOME_FOLDER_SCOPE);
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
|
||||
@@ -68,19 +68,20 @@ class Lists
|
||||
/*----------------------------------********---------------------------------*/
|
||||
];
|
||||
|
||||
// If the feature for highlight the home folders is disabled, add self-service list to the map
|
||||
if (!HIGHLIGHT_HOME_FOLDER_ENABLE) {
|
||||
$this->mapList['ListSelfService'] = 'CASES_SELFSERVICE';
|
||||
}
|
||||
|
||||
$this->ListInbox = new \ListInbox();
|
||||
$this->ListDraft = new \ListInbox();
|
||||
$this->ListCanceled = new \ListCanceled();
|
||||
$this->ListParticipated = new \ListParticipatedLast();
|
||||
$this->ListPaused = new \ListPaused();
|
||||
$this->ListCompleted = new \ListCompleted();
|
||||
$this->ListSelfService = new \ListUnassigned();
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$this->ListConsolidated = new Consolidated();
|
||||
// If the feature for highlight the home folders is disabled, add/initialize properties related to self-service list
|
||||
if (!HIGHLIGHT_HOME_FOLDER_ENABLE) {
|
||||
$this->mapList['ListSelfService'] = 'CASES_SELFSERVICE';
|
||||
$this->ListSelfService = new \ListUnassigned();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
|
||||
@@ -153,11 +154,8 @@ class Lists
|
||||
$listpeer = 'ListMyInboxPeer';
|
||||
break;
|
||||
case 'unassigned':
|
||||
// If the feature for highlight the home folders is disabled, initialize the variables for unassigned list
|
||||
if (!HIGHLIGHT_HOME_FOLDER_ENABLE) {
|
||||
$list = new \ListUnassigned();
|
||||
$listpeer = 'ListUnassignedPeer';
|
||||
}
|
||||
$list = new \ListUnassigned();
|
||||
$listpeer = 'ListUnassignedPeer';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user