PMC-1019
This commit is contained in:
41
tests/unit/workflow/engine/classes/model/IsoCountryTest.php
Normal file
41
tests/unit/workflow/engine/classes/model/IsoCountryTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use IsoCountry;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IsoCountryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the search for an isocountry
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_for_an_iso_country()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoCountry::findById('BO');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Bolivia', $res['IC_NAME']);
|
||||
|
||||
//Call the findById method
|
||||
$res = IsoCountry::findById('DE');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Germany', $res['IC_NAME']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result is null if the country does not exist
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_null_if_the_country_does_not_exist()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoCountry::findById('ZZ');
|
||||
//Assert the result is null
|
||||
$this->assertNull($res);
|
||||
}
|
||||
}
|
||||
41
tests/unit/workflow/engine/classes/model/IsoLocationTest.php
Normal file
41
tests/unit/workflow/engine/classes/model/IsoLocationTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use IsoLocation;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IsoLocationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the search for an iso location
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_for_an_iso_location()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoLocation::findById('BO', 'C', 'CBB');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Cochabamba', $res['IL_NAME']);
|
||||
|
||||
//Call the findById method
|
||||
$res = IsoLocation::findById('DE', 'NW', 'DUN');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Dulmen', $res['IL_NAME']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result is null if the location does not exist
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_null_if_the_location_does_not_exist()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoLocation::findById('ZZ', 'ZZ', 'ZZ');
|
||||
//Assert the result is null
|
||||
$this->assertNull($res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use IsoSubdivision;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IsoSubdivisionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the search for an iso subdivision
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_for_an_iso_subdivision()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoSubdivision::findById('BO', 'L');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('La Paz', $res['IS_NAME']);
|
||||
|
||||
//Call the findById method
|
||||
$res = IsoSubdivision::findById('DE', 'BE');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Berlin', $res['IS_NAME']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result is null if the subdivision does not exist
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_null_if_the_subdivision_does_not_exist()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoSubdivision::findById('ZZ', 'ZZ');
|
||||
//Assert the result is null
|
||||
$this->assertNull($res);
|
||||
}
|
||||
}
|
||||
71
tests/unit/workflow/engine/methods/users/UsersAjaxTest.php
Normal file
71
tests/unit/workflow/engine/methods/users/UsersAjaxTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\methods\users;
|
||||
|
||||
use ProcessMaker\Model\Configuration;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UsersAjaxTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up the deprecated errors
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the user ajax file with the userData action
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_the_user_ajax_file()
|
||||
{
|
||||
//Declare the global variable
|
||||
global $RBAC;
|
||||
//Creates the user factory
|
||||
$user = factory(User::class)->create();
|
||||
//Creates the configuration factory
|
||||
factory(Configuration::class)->create([
|
||||
'CFG_UID' => 'USER_PREFERENCES',
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => 'a:3:{s:12:"DEFAULT_LANG";s:0:"";s:12:"DEFAULT_MENU";s:8:"PM_SETUP";s:18:"DEFAULT_CASES_MENU";s:0:"";}',
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => $user['USR_UID'],
|
||||
'APP_UID' => '',
|
||||
]);
|
||||
|
||||
//Sets the needed variables
|
||||
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||
$_POST['action'] = 'userData';
|
||||
$_POST['USR_UID'] = $user['USR_UID'];
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
|
||||
//Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
//Call the tested file
|
||||
require_once PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/usersAjax.php';
|
||||
|
||||
//Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
//Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
//Decode the JSON string
|
||||
$res = json_decode($outputBuffer);
|
||||
|
||||
//Assert the call was success
|
||||
$this->assertTrue($res->success);
|
||||
//Assert the result corresponds to the user logged
|
||||
$this->assertEquals($user['USR_UID'], $res->user->USR_UID);
|
||||
//Assert the default menu is set
|
||||
$this->assertEquals('PM_EDIT_USER_PROFILE_DEFAULT_MAIN_MENU_OPTIONS',
|
||||
$res->permission->PREF_DEFAULT_MENUSELECTED);
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,6 @@ class Configuration extends Model
|
||||
protected $primaryKey = ['CFG_UID', 'OBJ_UID', 'PRO_UID', 'USR_UID', 'APP_UID'];
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
public $incrementing = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user