Merged in bugfix/PMCORE-3674 (pull request #8394)

PMCORE-3674

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Paula Quispe
2022-05-03 20:25:39 +00:00
committed by Julio Cesar Laura Avendaño
49 changed files with 1797 additions and 377 deletions

View File

@@ -10,7 +10,7 @@ $factory->define(\ProcessMaker\Model\Process::class, function (Faker $faker) {
return [
'PRO_UID' => G::generateUniqueID(),
'PRO_ID' => $faker->unique()->numberBetween(1000),
'PRO_ID' => $faker->unique()->numberBetween(2000),
'PRO_TITLE' => $faker->sentence(3),
'PRO_DESCRIPTION' => $faker->paragraph(3),
'PRO_PARENT' => G::generateUniqueID(),

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the capitalize() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#capitalize.28.29
*/
class CapitalizeTest extends TestCase
{
/**
* This tests the "capitalize"
* @test
*/
public function it_get_lower_case()
{
$result = capitalize('test');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Exception;
use Tests\TestCase;
/**
* Test the formatDate() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#formatDate.28.29
*/
class FormatDateTest extends TestCase
{
/**
* This tests the "formatDate"
* @test
*/
public function it_get_format_date()
{
$result = formatDate(date('Y-m-d'), 'yyyy-mm-dd');
$this->assertNotEmpty($result);
}
/**
* This tests the "formatDate"
* @test
*/
public function it_get_exceptions()
{
$this->expectException(Exception::class);
$result = formatDate('');
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the generateCode() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#generateCode.28.29
*/
class GenerateCodeTest extends TestCase
{
/**
* This tests the "generateCode"
* @test
*/
public function it_get_code()
{
$result = generateCode();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the getCurrentDate() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#getCurrentDate.28.29
*/
class GetCurrentDateTest extends TestCase
{
/**
* This tests the "getCurrentDate"
* @test
*/
public function it_get_current_date()
{
$result = getCurrentDate();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the getCurrentTime() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#getCurrentTime.28.29
*/
class GetCurrentTimeTest extends TestCase
{
/**
* This tests the "getCurrentTime"
* @test
*/
public function it_get_current_date()
{
$result = getCurrentTime();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Exception;
use Tests\TestCase;
/**
* Test the literalDate() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#literalDate.28.29
*/
class LiteralDateTest extends TestCase
{
/**
* This tests the "literalDate"
* @test
*/
public function it_get_literal_date()
{
$result = literalDate(date('Y-m-d'), 'en');
$this->assertNotEmpty($result);
$result = literalDate(date('Y-m-d'), 'es');
$this->assertNotEmpty($result);
}
/**
* This tests the "literalDate"
* @test
*/
public function it_get_exceptions()
{
$this->expectException(Exception::class);
$result = literalDate('');
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the lowerCase() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#lowerCase.28.29
*/
class LowerCaseTest extends TestCase
{
/**
* This tests the "lowerCase"
* @test
*/
public function it_get_lower_case()
{
$result = lowerCase('TEST');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the orderGrid() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#generateCode.28.29
*/
class OrderGridTest extends TestCase
{
/**
* This tests the "orderGrid"
* @test
*/
public function it_test_order_grid()
{
$grid = [];
$grid[1]['NAME'] = 'Jhon';
$grid[1]['AGE'] = 27;
$grid[2]['NAME'] = 'Louis';
$grid[2]['AGE'] = 5;
$result = orderGrid($grid, 'AGE', 'ASC');
$this->assertNotEmpty($result);
$result = orderGrid($result, 'AGE', 'DESC');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* Test the PMFAddCaseNote() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Case_Notes_Functions#PMFGetCaseNotes.28.29
*/
class PMFAddCaseNoteTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFAddCaseNote"
* @test
*/
public function it_add_case_notes()
{
// Create notes
$table = factory(Delegation::class)->states('foreign_keys')->create();
// Force commit for propel
DB::commit();
$result = PMFAddCaseNote($table->APP_UID, $table->PRO_UID, $table->TAS_UID, $table->USR_UID, 'note');
$this->assertTrue($result >= 0);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\RbacUsers;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFAssignUserToGroup() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Group_Functions#PMFAssignUserToGroup.28.29
*/
class PMFAssignUserToGroupTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFAssignUserToGroup"
* @test
*/
public function it_assign_user_to_group()
{
// Create user
global $RBAC;
$user = factory(User::class)->create();
factory(RbacUsers::class)->create([
'USR_UID' => $user->USR_UID,
'USR_USERNAME' => $user->USR_USERNAME,
'USR_FIRSTNAME' => $user->USR_FIRSTNAME,
'USR_LASTNAME' => $user->USR_LASTNAME
]);
// Create group
$group = factory(Groupwf::class)->create();
DB::commit();
$result = PMFAssignUserToGroup($user->USR_UID, $group->GRP_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -6,7 +6,6 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use RBAC;
use Tests\TestCase;
/**

View File

@@ -0,0 +1,36 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\AppThread;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* Test the PMFCaseList() function
*
* @link https://wiki.processmaker.com/3.7/ProcessMaker_Functions/Case_Functions#PMFCaseList.28.29
*/
class PMFCaseListTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFCaseList"
* @test
*/
public function it_return_list_of_cases()
{
// Create delegation
$table = factory(Delegation::class)->states('foreign_keys')->create();
factory(AppThread::class)->create([
'APP_THREAD_STATUS' => 'OPEN',
'APP_UID' => $table->APP_UID
]);
DB::commit();
$result = PMFCaseList($table->USR_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\RbacUsers;
use ProcessMaker\Model\User;
use RBAC;
use Tests\TestCase;
/**
* Test the PMFCreateUser() function
*
* @link https://wiki.processmaker.com/3.7/ProcessMaker_Functions/User_Functions#PMFCreateUser.28.29
*/
class PMFCreateUserTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests the "PMFCreateUser"
* @test
*/
public function it_create_user()
{
// Create User
$user = factory(User::class)->create();
factory(RbacUsers::class)->create([
'USR_UID' => $user->USR_UID,
'USR_USERNAME' => $user->USR_USERNAME,
'USR_FIRSTNAME' => $user->USR_FIRSTNAME,
'USR_LASTNAME' => $user->USR_LASTNAME
]);
DB::commit();
$result = PMFCreateUser('jsmith', 'PaSsWoRd', 'John', 'Smith', 'jsmith@company.com', 'PROCESSMAKER_OPERATOR');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Exception;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Triggers;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* Test the PMFDeleteCase() function
*
* @link https://wiki.processmaker.com/3.7/ProcessMaker_Functions/Case_Functions#PMFDeleteCase.28.29
*/
class PMFDeleteCaseTest extends TestCase
{
use DatabaseTransactions;
/**
* It tests the PMFDeleteCaseTest() function with the default parameters
*
* @test
*/
public function it_should_test_this_pmfunction_default_parameters()
{
$this->expectException(Exception::class);
$table = factory(Delegation::class)->states('foreign_keys')->create();
factory(Triggers::class)->create([
'PRO_UID' => $table->PRO_UID
]);
// Force commit for propel
DB::commit();
$result = PMFDeleteCase($table->APP_UID);
$this->assertEquals(0, $result);
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\AppNotes;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFGetCaseNotes() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Case_Notes_Functions#PMFGetCaseNotes.28.29
*/
class PMFGetCaseNotesTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetCaseNotes"
* @test
*/
public function it_get_case_notes()
{
// Create notes
$user = factory(User::class)->create();
$table = factory(AppNotes::class)->create([
'USR_UID' => $user->USR_UID
]);
// Force commit for propel
DB::commit();
$result = PMFGetCaseNotes($table->APP_UID, 'array');
$this->assertNotEmpty($result);
$result = PMFGetCaseNotes($table->APP_UID, 'object');
$this->assertNotEmpty($result);
$result = PMFGetCaseNotes($table->APP_UID, 'string');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Groupwf;
use Tests\TestCase;
/**
* Test the PMFGetGroupName() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFGetGroupName.28.29
*/
class PMFGetGroupNameTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetGroupName"
* @test
*/
public function it_get_group_name()
{
// Create group
$group = factory(Groupwf::class)->create();
DB::commit();
$result = PMFGetGroupName($group->GRP_TITLE, 'en');
$this->assertFalse($result);
// When is empty
$result = PMFGetGroupName('');
$this->assertFalse($result);
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Groupwf;
use Tests\TestCase;
/**
* Test the PMFGetGroupUID() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFGetGroupUID.28.29
*/
class PMFGetGroupUIDTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetGroupUID"
* @test
*/
public function it_group_uid()
{
// Create group
$group = factory(Groupwf::class)->create();
$result = PMFGetGroupUID($group->GRP_UID);
$this->assertFalse($result);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Groupwf;
use Tests\TestCase;
/**
* Test the PMFGetGroupUsers() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFGetGroupUsers.28.29
*/
class PMFGetGroupUsersTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetGroupUsers"
* @test
*/
public function it_return_list_of_groups()
{
// Create group
$group = factory(Groupwf::class)->create();
DB::commit();
$result = PMFGetGroupUsers($group->GRP_UID);
$this->assertEmpty($result);
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Process;
use Tests\TestCase;
/**
* Test the PMFGetProcessUidByName() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Process_Functions#PMFGetProcessUidByName.28.29
*/
class PMFGetProcessUidByNameTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetProcessUidByName"
* @test
*/
public function it_return_process()
{
// Create process
$table = factory(Process::class)->create();
DB::commit();
$result = PMFGetProcessUidByName($table->PRO_TITLE);
$this->assertNotEmpty($result);
// When a process was defined in the session
$result = PMFGetProcessUidByName('');
$this->assertNotEmpty($result);
// When does not defined the session
$_SESSION['PROCESS'] = '';
$result = PMFGetProcessUidByName('');
$this->assertEmpty($result);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Task;
use Tests\TestCase;
/**
* Test the PMFGetTaskName() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFGetTaskName.28.29
*/
class PMFGetTaskNameTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetTaskName"
* @test
*/
public function it_return_task_name()
{
// Create task
$task = factory(Task::class)->create();
DB::commit();
$result = PMFGetTaskName($task->TAS_UID);
$this->assertNotEmpty($result);
// When is empty
$result = PMFGetTaskName('');
$this->assertFalse($result);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Task;
use Tests\TestCase;
/**
* Test the PMFGetTaskUID() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFGetTaskUID.28.29
*/
class PMFGetTaskUIDTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGetTaskUID"
* @test
*/
public function it_return_task_uid()
{
// Create task
$table = factory(Task::class)->states('foreign_keys')->create();
DB::commit();
$result = PMFGetTaskUID($table->TAS_TITLE);
$this->assertFalse($result);
// When is empty
$result = PMFGetTaskUID($table->TAS_TITLE, $table->PRO_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFGetUserEmailAddress() function
*/
class PMFGetUserEmailAddressTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests the "PMFGetUserEmailAddress"
* @test
*/
public function it_get_user_mail()
{
// Create User
global $RBAC;
$user = factory(User::class)->create();
DB::commit();
$result = PMFGetUserEmailAddress([$user->USR_UID], null);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Groupwf;
use Tests\TestCase;
/**
* Test the PMFGroupList() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Group_Functions#PMFGroupList.28.29
*/
class PMFGroupListTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFGroupList"
* @test
*/
public function it_return_list_of_groups()
{
// Create group
factory(Groupwf::class)->create();
DB::commit();
$result = PMFGroupList();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFInformationUser() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/User_Functions#PMFInformationUser.28.29
*/
class PMFInformationUserTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFInformationUser"
* @test
*/
public function it_return_list_of_process()
{
// Create User
global $RBAC;
$user = factory(User::class)->create();
DB::commit();
$result = PMFInformationUser($user->USR_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* Test the PMFNewCaseImpersonate() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFNewCaseImpersonate.28.29
*/
class PMFNewCaseImpersonateTest extends TestCase
{
use DatabaseTransactions;
/**
* It tests the PMFNewCaseImpersonateTest() function with the default parameters
*
* @test
*/
public function it_should_test_this_pmfunction_default_parameters()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
// Force commit for propel
DB::commit();
$result = PMFNewCaseImpersonate($table->PRO_UID, $table->USR_UID, [], '');
$this->assertEquals(0, $result);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* Test the PMFNewCase() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFNewCase.28.29
*/
class PMFNewCaseTest extends TestCase
{
use DatabaseTransactions;
/**
* It tests the PMFNewCaseTest() function with the default parameters
*
* @test
*/
public function it_should_test_this_pmfunction_default_parameters()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
// Force commit for propel
DB::commit();
$result = PMFNewCase($table->PRO_UID, $table->USR_UID, $table->TAS_UID, [], null);
$this->assertEquals(0, $result);
}
}

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\RbacUsers;
@@ -9,6 +11,9 @@ use ProcessMaker\Model\User;
use RBAC;
use Tests\TestCase;
/**
* Test the PMFNewUserTest() function
*/
class PMFNewUserTest extends TestCase
{
/**
@@ -53,10 +58,11 @@ class PMFNewUserTest extends TestCase
$group = factory(Groupwf::class)->create();
// Active
$result = PMFNewUser("test", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, null, $group['GRP_UID']);
$query = GroupUser::select();
$r = $query->get()->values()->toArray();
$r = $query->where('GRP_UID', $group['GRP_UID'])->get()->values()->toArray();
$this->assertEquals($r[0]['GRP_UID'], $result['groupUid']);
$this->assertEquals($r[0]['USR_UID'], $result['userUid']);
@@ -67,6 +73,14 @@ class PMFNewUserTest extends TestCase
$this->assertNotEmpty($r);
$this->assertEquals($result['userUid'], $r[0]['USR_UID']);
$this->assertEquals($result['username'], $r[0]['USR_USERNAME']);
// Vacation
$result = PMFNewUser("test11", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, 'VACATION', $group['GRP_UID']);
$this->assertEquals('VACATION', $result['status']);
// Inactive
$result = PMFNewUser("test22", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, 'INACTIVE', $group['GRP_UID']);
$this->assertEquals('INACTIVE', $result['status']);
}
/**

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Process;
use Tests\TestCase;
/**
* Test the PMFProcessList() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Process_Functions#PMFProcessList.28.29
*/
class PMFProcessListTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFProcessList"
* @test
*/
public function it_return_list_of_process()
{
// Create delegation
factory(Process::class)->create();
$result = PMFProcessList();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the PMFRemoveMask() function
*/
class PMFRemoveMaskTest extends TestCase
{
/**
* This tests the "PMFRemoveMask"
* @test
*/
public function it_get_literal_date()
{
$result = PMFRemoveMask('35.5');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFGetGroupUsers() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFGetGroupUsers.28.29
*/
class PMFRemoveUsersFromGroupTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFRemoveUsersFromGroup"
* @test
*/
public function it_remove_user_group()
{
// Create group
$user = factory(User::class)->create();
$group = factory(Groupwf::class)->create();
$groupUser = factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' =>$user->USR_UID
]);
DB::commit();
$result = PMFRemoveUsersFromGroup($groupUser->GRP_UID, [$groupUser->USR_UID]);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFGetGroupUsers() function
*
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFRemoveUsersToGroup.28.29
*/
class PMFRemoveUsersToGroupTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFRemoveUsersToGroup"
* @test
*/
public function it_remove_user_group()
{
// Create group
$user = factory(User::class)->create();
$group = factory(Groupwf::class)->create();
$groupUser = factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' =>$user->USR_UID
]);
DB::commit();
$result = PMFRemoveUsersToGroup($groupUser->GRP_UID, [$groupUser->USR_UID]);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\RbacRoles;
use Tests\TestCase;
/**
* Test the PMFRoleList() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Group_Functions#PMFRoleList.28.29
*/
class PMFRoleListTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFRoleList"
* @test
*/
public function it_return_list_of_roles()
{
// Create roles
global $RBAC;
factory(RbacRoles::class)->create();
DB::commit();
$result = PMFRoleList();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use Tests\TestCase;
/**
* Test the PMFTaskCase() function
*
* @link https://wiki.processmaker.com/3.3/ProcessMaker_Functions/Case_Functions#PMFTaskCase.28.29
*/
class PMFTaskCaseTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFTaskCase"
* @test
*/
public function it_return_pending_tasks()
{
$task = factory(Task::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID
]);
DB::commit();
$result = PMFTaskCase($table->APP_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFTaskList() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Task_Functions#PMFTaskList.28.29
*/
class PMFTaskListTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFTaskList"
* @test
*/
public function it_return_pending_tasks()
{
// Create task
$task = factory(Task::class)->create();
// Create user
$user = factory(User::class)->create();
// Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
DB::commit();
$result = PMFTaskList($user->USR_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Task;
use Tests\TestCase;
/**
* Test the PMFTasksListByProcessId() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Task_Functions#PMFTaskList.28.29
*/
class PMFTasksListByProcessIdTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFTasksListByProcessId"
* @test
*/
public function it_return_process_tasks()
{
// Create task
$task = factory(Task::class)->create();
DB::commit();
$result = PMFTasksListByProcessId($task->PRO_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Exception;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* Test the PMFUnpauseCase() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFUnpauseCase.28.29
*/
class PMFUnpauseCaseTest extends TestCase
{
use DatabaseTransactions;
/**
* It tests the PMFUnpauseCaseTest() function with the default parameters
*
* @test
*/
public function it_should_test_this_pmfunction_default_parameters()
{
$this->expectException(Exception::class);
$table = factory(Delegation::class)->states('foreign_keys')->create();
// Force commit for propel
DB::commit();
$result = PMFUnpauseCase($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
$this->assertEquals(0, $result);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFUpdateUser() function
*
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFUpdateUser.28.29
*/
class PMFUpdateUserTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests the "PMFUpdateUser"
* @test
*/
public function it_update_user()
{
// Create User
global $RBAC;
$user = factory(User::class)->create();
DB::commit();
$result = PMFUpdateUser($user->USR_UID, $user->USR_USERNAME, 'John A.');
$this->assertEquals(0, $result);
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the PMFUserList() function
*
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/User_Functions#PMFUserList.28.29
*/
class PMFUserListTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests if the "PMFUserList"
* @test
*/
public function it_return_list_of_users()
{
// Create user
$user = factory(User::class)->create();
$result = PMFUserList();
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the pmSqlEscape() function
*/
class PmSqlEscapeTest extends TestCase
{
/**
* This tests the "pmSqlEscape"
* @test
*/
public function it_get_sql_escape()
{
$value = 'select uid from user';
$result = pmSqlEscape($value);
$this->assertEquals($result, $value);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the pmToFloat() function
*/
class PmToFloatTest extends TestCase
{
/**
* This tests the "pmToFloat"
* @test
*/
public function it_get_float()
{
$value = '1.2';
$result = pmToFloat($value);
$this->assertEquals($result, 1.2);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the pmToInteger() function
*/
class PmToIntegerTest extends TestCase
{
/**
* This tests the "pmToInteger"
* @test
*/
public function it_get_int()
{
$value = '1';
$result = pmToInteger($value);
$this->assertEquals($result, 1);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the pmToString() function
*/
class PmToStringTest extends TestCase
{
/**
* This tests the "pmToString"
* @test
*/
public function it_get_string()
{
$value = 1;
$result = pmToString($value);
$this->assertEquals($result, '1');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the pmToUrl() function
*/
class PmToUrlTest extends TestCase
{
/**
* This tests the "pmToUrl"
* @test
*/
public function it_get_url()
{
$value = 'home';
$result = pmToUrl($value);
$this->assertEquals($result, $value);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Tests\TestCase;
/**
* Test the upperCase() function
*/
class UpperCaseTest extends TestCase
{
/**
* This tests the "upperCase"
* @test
*/
public function it_get_upper_case()
{
$result = upperCase('test');
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Test the userInfo() function
*/
class UserInfoTest extends TestCase
{
use DatabaseTransactions;
/**
* This tests the "userInfo"
* @test
*/
public function it_get_user_info()
{
// Create User
global $RBAC;
$user = factory(User::class)->create();
DB::commit();
$result = userInfo($user->USR_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -7079,7 +7079,7 @@ class Cases
* @return array|stdclass|string
*
*/
public function getCaseNotes($applicationID, $type = 'array', $userUid = '')
public static function getCaseNotes($applicationID, $type = 'array', $userUid = '')
{
require_once("classes/model/AppNotes.php");
$appNotes = new AppNotes();
@@ -7108,6 +7108,7 @@ class Cases
case 'object':
$response = new stdclass();
foreach ($appNotes['array']['notes'] as $key => $value) {
$response->$key = new stdclass();
$response->$key->FULL_NAME = $value['USR_FIRSTNAME'] . " " . $value['USR_LASTNAME'];
foreach ($value as $keys => $value) {
if ($keys != 'USR_FIRSTNAME' && $keys != 'USR_LASTNAME' && $keys != 'USR_EMAIL') {

View File

@@ -1204,7 +1204,9 @@ class WsBase
{
try {
global $RBAC;
if (is_null($RBAC)) {
$RBAC = RBAC::getSingleton();
}
$RBAC->initRBAC();
if (empty($userName)) {
@@ -1715,6 +1717,9 @@ class WsBase
{
try {
global $RBAC;
if (is_null($RBAC)) {
$RBAC = RBAC::getSingleton();
}
$RBAC->initRBAC();
$user = $RBAC->verifyUserId($userId);

File diff suppressed because it is too large Load Diff