PMCORE-3985 PHP Unit, solve the issue in the Circle CI

This commit is contained in:
Roly Gutierrez
2022-09-14 12:08:21 -04:00
parent f7112d18e9
commit cc36bbe277
12 changed files with 39 additions and 41 deletions

View File

@@ -39,11 +39,11 @@ class WorkflowToolsTest extends TestCase
ob_start();
$this->workspaceTools->addAsyncOptionToSchedulerCommands(false);
$string = ob_get_clean();
$this->assertRegExp("/This was previously updated/", $string);
$this->assertMatchesRegularExpression("/This was previously updated/", $string);
ob_start();
$this->workspaceTools->addAsyncOptionToSchedulerCommands(true);
$string = ob_get_clean();
$this->assertRegExp("/Adding \+async option/", $string);
$this->assertMatchesRegularExpression("/Adding \+async option/", $string);
}
}

View File

@@ -11,11 +11,13 @@ class WorkspaceToolsTest extends TestCase
public $workspace;
/**
* Call the setUp parent method
* Set up method.
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
parent::setUp();
$this->truncateNonInitialModels();
config(["system.workspace" => "new_site"]);
$this->workspace = config("system.workspace");
@@ -31,26 +33,16 @@ class WorkspaceToolsTest extends TestCase
public function it_should_test_upgrade_Iso_Country_method()
{
$workspaceTools = new WorkspaceTools($this->workspace);
$workspaceTools->updateIsoCountry();
$workspaceTools->updateIsoCountry();
$result = ob_get_contents();
$this->assertRegExp("/-> Update table ISO_COUNTRY Done/", $result);
$this->assertMatchesRegularExpression("/-> Update table ISO_COUNTRY Done/", $result);
$res = IsoCountry::findById('CI');
// Assert the result is the expected
$this->assertEquals('Côte d\'Ivoire', $res['IC_NAME']);
}
/**
* Set up method.
* @return void
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
* Tests the migrateCaseTitleToThreads method
*
@@ -149,7 +141,7 @@ class WorkspaceToolsTest extends TestCase
$result = ob_get_contents();
ob_end_clean();
$this->assertMatchesRegularExpression("/The Case Title has been updated successfully in APP_DELEGATION table./", $result);
$r = Delegation::select('DEL_TITLE')->where('DELEGATION_ID', $delegation1->DELEGATION_ID)->get()->values()->toArray();
$this->assertEquals($r[0]['DEL_TITLE'], $application1->APP_TITLE);

View File

@@ -15,7 +15,7 @@ class ProxyNewCasesListTest extends TestCase
/**
* This sets the initial parameters for each test.
*/
public function setUp()
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
$this->settingUserLogged();

View File

@@ -368,7 +368,7 @@ class EmailServerTest extends TestCase
$emailServer = new EmailServer();
// This expects an exception message
$this->expectExceptionMessage('Undefined array key "MESS_ENGINE"');
$this->expectException('ErrorException');
// Call the sendTestMail method
$emailServer->sendTestMail($data);

View File

@@ -114,9 +114,10 @@ class WebEntryTest extends TestCase
$webEntryFilename = 'My_Custom_Form';
//assert true result
$webEntry = factory(WebEntry::class)->create([
$webEntry = WebEntry::factory()->create([
'WE_DATA' => $webEntryFilename . $phpExtension,
'WE_HIDE_ACTIVE_SESSION_WARNING' => '0'
'WE_HIDE_ACTIVE_SESSION_WARNING' => '0',
'WE_AUTHENTICATION' => 'LOGIN_REQUIRED'
]);
$weUid = $webEntry->WE_UID;
@@ -126,9 +127,10 @@ class WebEntryTest extends TestCase
$this->assertEquals($result, true);
//assert false result
$webEntry = factory(WebEntry::class)->create([
$webEntry = WebEntry::factory()->create([
'WE_DATA' => $webEntryFilename . $phpExtension,
'WE_HIDE_ACTIVE_SESSION_WARNING' => '1'
'WE_HIDE_ACTIVE_SESSION_WARNING' => '1',
'WE_AUTHENTICATION' => 'LOGIN_REQUIRED'
]);
$weUid = $webEntry->WE_UID;

View File

@@ -368,6 +368,6 @@ class GmailOAuthTest extends TestCase
$res = $gmailOauth->getMessageBody();
// Assert the result contains the server protocol and host
$this->assertRegExp("#" . System::getServerProtocol() . System::getServerHost() . "#", $res);
$this->assertMatchesRegularExpression("#" . System::getServerProtocol() . System::getServerHost() . "#", $res);
}
}

View File

@@ -155,7 +155,7 @@ class DelegationTest extends TestCase
*/
public function it_return_scope_thread_id_open()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$table = Delegation::factory()->foreign_keys()->create();
$this->assertCount(1, $table->threadIdOpen()->get());
}

View File

@@ -678,7 +678,7 @@ class MetricsTest extends TestCase
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$this->expectExceptionMessage('Undefined variable $list');
$this->expectException('Luracast\Restler\RestException');
$metrics->getProcessTotalCases(12, 123, "asda");
}
@@ -695,7 +695,7 @@ class MetricsTest extends TestCase
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$this->expectExceptionMessage('Undefined variable $list');
$this->expectException('Luracast\Restler\RestException');
$metrics->getTotalCasesByRange(12, 123, "asda");
}
@@ -712,7 +712,7 @@ class MetricsTest extends TestCase
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$this->expectExceptionMessage('Undefined variable $list');
$this->expectException('Luracast\Restler\RestException');
$metrics->getCasesRiskByProcess(12, 123, "asda");
}
}

View File

@@ -3,7 +3,6 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api;
use Faker\Factory;
use Luracast\Restler\RestException;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\User;
use ProcessMaker\Model\RbacUsers;
@@ -29,6 +28,11 @@ class ProjectTest extends TestCase
*/
public function it_should_set_the_process_owner_with_invalid_value()
{
$workspace = config("system.workspace");
$cacheFolder = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP . "cachefiles" . PATH_SEP;
if (!file_exists($cacheFolder)) {
mkdir($cacheFolder, 0777, true);
}
$filename = PATH_TRUNK . "tests/resources/p1normal-2.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
@@ -51,18 +55,18 @@ class ProjectTest extends TestCase
*/
public function it_should_test_the_do_get_process_method()
{
$this->markTestSkipped("Propel doesn't have connection to database php8");
//Create user
$user = User::factory()->create();
RbacUsers::factory()->create([
'USR_UID' => $user->USR_UID,
'USR_USERNAME' => $user->USR_USERNAME,
'USR_FIRSTNAME' => $user->USR_FIRSTNAME,
'USR_LASTNAME' => $user->USR_LASTNAME
'USR_UID' => $this->user->USR_UID,
'USR_USERNAME' => $this->user->USR_USERNAME,
'USR_FIRSTNAME' => $this->user->USR_FIRSTNAME,
'USR_LASTNAME' => $this->user->USR_LASTNAME
]);
//Create process
$process = Process::factory()->create([
'PRO_CREATE_USER' => $user->USR_UID,
'PRO_CREATE_USER' => $this->user->USR_UID,
'PRO_STATUS' => 'ACTIVE',
'PRO_TYPE_PROCESS' => 'PRIVATE',
]);

View File

@@ -37,7 +37,7 @@ class UpdateUserLastLoginTest extends TestCase
$userLog = ['USR_UID' => $user['USR_UID']];
// Assert the expected exception
$this->expectExceptionMessage('Undefined array key "LOG_INIT_DATE"');
$this->expectException('Exception');
// Call the updateUserLastLogin function
updateUserLastLogin($userLog);