PMCORE-3993 Circle CI: Research the Enable the coverage in PHPUnit 9.5.0 in develop

This commit is contained in:
Roly Gutierrez
2022-11-10 20:29:56 -04:00
parent 693602eaab
commit e8b0b3b273
41 changed files with 527 additions and 90 deletions

View File

@@ -4,7 +4,7 @@ jobs:
working_directory: ~/processmaker
docker:
- image: devopsstacks/pm:n285-phpunit
- image: circleci/mysql:8.0.13-ram
- image: cimg/mysql:8.0
command: |
mysqld --default-authentication-plugin='mysql_native_password' --optimizer-switch='derived_merge=off' --sql-mode='NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' --collation-server='utf8mb4_unicode_ci' --character-set-server='utf8mb4' --max_connections=500
environment:
@@ -28,10 +28,12 @@ jobs:
name: Run Test Units
command: |
mkdir -p coverage
vendor/phpunit/phpunit/phpunit --stop-on-error --testdox-html coverage/result.html --coverage-html coverage --verbose tests/unit/
vendor/bin/phpunit --stop-on-error --testdox-html coverage/result.html --coverage-html coverage --verbose tests/unit/
environment:
XDEBUG_MODE: coverage
- store_artifacts:
path: coverage
destination: coverage
- store_test_results:
path: coverage

View File

@@ -25,6 +25,21 @@
</testsuite>
</testsuites>
<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./gulliver</directory>
<directory suffix=".php">./rbac</directory>
<directory suffix=".php">./workflow</directory>
</include>
<exclude>
<directory>./workflow/engine/classes/model/map</directory>
<directory>./workflow/engine/classes/model/om</directory>
<directory>./workflow/public_html</directory>
<directory>./workflow/engine/templates</directory>
</exclude>
</coverage>
<php>
<!--Main environment-->
<env name="MAIN_SYS_SYS" value="workflow" />

View File

@@ -4,8 +4,7 @@ namespace Tests;
use App\Factories\Factory;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\DB;
use Propel;
use mysqli;
abstract class TestCase extends BaseTestCase
{
@@ -84,9 +83,8 @@ abstract class TestCase extends BaseTestCase
* truncate non-initial Models.
* @return void
*/
public function truncateNonInitialModels(): void
public static function truncateNonInitialModels(): void
{
DB::statement("set global max_connections = 500;");
if (empty(static::$truncateInitialTables)) {
$initialTables = [
'RBAC_PERMISSIONS',
@@ -135,12 +133,15 @@ abstract class TestCase extends BaseTestCase
}
static::$truncateInitialTables = implode(';', $truncates);
}
} else {
DB::unprepared(
"SET FOREIGN_KEY_CHECKS = 0;" .
static::$truncateInitialTables .
";SET FOREIGN_KEY_CHECKS = 1;"
);
}
$mysqli = new mysqli(env('DB_HOST'), env('DB_USERNAME'), env('DB_PASSWORD'), env('DB_DATABASE'));
$mysqli->multi_query(
"set global max_connections = 500;" .
"SET FOREIGN_KEY_CHECKS = 0;" .
static::$truncateInitialTables .
";SET FOREIGN_KEY_CHECKS = 1;"
);
// flush multi_queries
while ($mysqli->next_result()) {;}
}
}

View File

@@ -149,7 +149,7 @@ class CliWorkspacesTest extends TestCase
/**
* Test the queries incompatibilities in dynaforms
*
* @covers WorkspaceTools::check_queries_incompatibilities
* @covers check_queries_incompatibilities
* @test
*/
public function it_should_test_the_incompatibilities_in_the_dynaforms_queries()

View File

@@ -15,25 +15,6 @@ use Tests\TestCase;
class CasesTest extends TestCase
{
protected $preserveGlobalState = false;
protected $runTestInSeparateProcess = true;
/**
* Call setUp method
*/
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
}
/**
* Call the tearDown method
*/
public function tearDown(): void
{
// The parent method needs to be override due to errors appearing
}
/**
* Test getNextStep method with no steps
*

View File

@@ -12,6 +12,16 @@ use Tests\TestCase;
*/
class PmDynaformTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@@ -35,7 +45,6 @@ class PmDynaformTest extends TestCase
if (!defined("DB_PASS")) {
define("DB_PASS", env('DB_PASSWORD'));
}
$this->truncateNonInitialModels();
}
/**

File diff suppressed because one or more lines are too long

View File

@@ -10,6 +10,16 @@ class WorkspaceToolsTest extends TestCase
use CreateTestSite;
public $workspace;
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Set up method.
* @return void
@@ -17,7 +27,6 @@ class WorkspaceToolsTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
config(["system.workspace" => "new_site"]);
$this->workspace = config("system.workspace");

View File

@@ -12,13 +12,22 @@ class GroupsAjaxTest extends TestCase
{
private $groups;
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Set up function
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
$this->settingUserLogged();
$this->createGroups();
}

View File

@@ -16,6 +16,16 @@ use Tests\TestCase;
class ActionsByEmailTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
*
* @return void
@@ -23,7 +33,6 @@ class ActionsByEmailTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -274,6 +283,7 @@ class ActionsByEmailTest extends TestCase
*/
public function it_should_test_the_load_action_by_email_method()
{
self::truncateNonInitialModels();
$user = User::factory()->create();
$application = Application::factory()->create([
'APP_UID' => '123456asse'

View File

@@ -23,13 +23,31 @@ use Tests\TestCase;
*/
class AbstractCasesTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -14,13 +14,31 @@ use Tests\TestCase;
*/
class BatchRoutingTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -14,13 +14,31 @@ use Tests\TestCase;
*/
class CanceledTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -14,13 +14,31 @@ use Tests\TestCase;
*/
class CasesListTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -14,13 +14,31 @@ use Tests\TestCase;
*/
class CompletedTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -21,13 +21,31 @@ use Tests\TestCase;
*/
class DraftTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -337,6 +355,7 @@ class DraftTest extends TestCase
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
Delegation::truncate();
$process = Process::factory()->create();
$process2 = Process::factory()->create();
$user = User::factory()->create();
@@ -675,6 +694,7 @@ class DraftTest extends TestCase
*/
public function it_should_test_get_counters_by_range_method()
{
Delegation::truncate();
$process1 = Process::factory()->create();
$process2 = Process::factory()->create();
$user = User::factory()->create();

View File

@@ -25,13 +25,31 @@ use Tests\TestCase;
*/
class HomeTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* setUp method.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -20,13 +20,31 @@ use Tests\TestCase;
*/
class InboxTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -416,6 +434,7 @@ class InboxTest extends TestCase
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
Delegation::truncate();
$user = User::factory()->create();
$process = Process::factory()->create();
$process2 = Process::factory()->create();
@@ -685,6 +704,7 @@ class InboxTest extends TestCase
*/
public function it_should_test_get_counters_by_range_method()
{
Delegation::truncate();
$user = User::factory()->create();
$process = Process::factory()->create();
$process2 = Process::factory()->create();

View File

@@ -15,13 +15,31 @@ use Tests\TestCase;
*/
class ParticipatedTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -424,6 +442,7 @@ class ParticipatedTest extends TestCase
*/
public function it_filter_by_thread_title()
{
Delegation::truncate();
// Create factories related to the participated cases
$cases = $this->createParticipated();
// We need to commit the records inserted because is needed for the "fulltext" index

View File

@@ -23,13 +23,31 @@ use Tests\TestCase;
*/
class PausedTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -357,6 +375,7 @@ class PausedTest extends TestCase
*/
public function it_filter_by_thread_title()
{
Delegation::truncate();
// Create factories related to the paused cases
$cases = $this->createPaused();
// We need to commit the records inserted because is needed for the "fulltext" index
@@ -469,6 +488,7 @@ class PausedTest extends TestCase
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
Delegation::truncate();
$cases = $this->createMultiplePaused(2);
$paused = new Paused();
$paused->setUserId($cases->USR_ID);
@@ -581,6 +601,7 @@ class PausedTest extends TestCase
*/
public function it_should_test_get_counters_by_range_method()
{
Delegation::truncate();
$user = User::factory()->create();
$process1 = Process::factory()->create();
$task = Task::factory()->create([

View File

@@ -15,13 +15,31 @@ use Tests\TestCase;
*/
class SearchTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Set up function.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -20,13 +20,31 @@ use Tests\TestCase;
*/
class SupervisingTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -384,6 +402,7 @@ class SupervisingTest extends TestCase
*/
public function it_filter_by_thread_title()
{
Delegation::truncate();
// Create factories related to the to_do cases
$cases = $this->createSupervising();
$usrUid = $cases->USR_UID;

View File

@@ -27,13 +27,31 @@ use Tests\TestCase;
*/
class UnassignedTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* This method is called after the last test of this test class is run.
*/
public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
self::truncateNonInitialModels();
}
/**
* Method set up.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -495,6 +513,8 @@ class UnassignedTest extends TestCase
*/
public function it_filter_by_thread_title()
{
Delegation::truncate();
Application::truncate();
// Create factories related to the unassigned cases
$cases = $this->createSelfServiceUserOrGroup();
$usrUid = $cases['taskUser']->USR_UID;
@@ -573,6 +593,7 @@ class UnassignedTest extends TestCase
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
Delegation::truncate();
$cases = $this->createMultipleUnassigned(3);
$unassigned = new Unassigned();
$unassigned->setUserId($cases['taskUser']->USR_ID);
@@ -735,6 +756,7 @@ class UnassignedTest extends TestCase
*/
public function it_should_test_get_counters_by_range_method()
{
Delegation::truncate();
$user = User::factory()->create();
$process1 = Process::factory()->create([
'CATEGORY_ID' => 2

View File

@@ -25,13 +25,22 @@ use Tests\TestCase;
*/
class CasesTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Set up method.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
User::where('USR_ID', '=', 1)
->where('USR_ID', '=', 2)
->delete();
@@ -330,6 +339,7 @@ class CasesTest extends TestCase
*/
public function it_should_test_get_dynaforms_by_application()
{
Application::truncate();
// Create a process
$process = Process::factory()->create();

View File

@@ -23,12 +23,16 @@ class GranularImporterTest extends TestCase
* It should return data from addObjectData() method.
* @test
* @covers \ProcessMaker\BusinessModel\Migrator\GranularImporter::addObjectData()
* @dataProvider importDataObject
*/
public function it_should_return_data_from_add_object_data_method($name, $data)
public function it_should_return_data_from_add_object_data_method()
{
$granularImporter = new GranularImporter();
$result = $granularImporter->addObjectData($name, $data);
$this->assertArrayHasKey($name, $result);
$data = $this->importDataObject();
foreach ($data as $value) {
$name = $value[0];
$data = $value[1];
$granularImporter = new GranularImporter();
$result = $granularImporter->addObjectData($name, $data);
$this->assertArrayHasKey($name, $result);
}
}
}

View File

@@ -8,13 +8,22 @@ use Tests\TestCase;
class TableTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Method setUp.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -8,6 +8,16 @@ use Tests\TestCase;
class TaskSchedulerBMTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Set up method.
* @return void
@@ -15,7 +25,6 @@ class TaskSchedulerBMTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -94,6 +103,7 @@ class TaskSchedulerBMTest extends TestCase
*/
public function it_should_test_generate_initial_data_method()
{
TaskScheduler::truncate();
$r = TaskScheduler::all()->toArray();
$this->assertEmpty($r);

View File

@@ -10,6 +10,15 @@ use Tests\TestCase;
class SystemTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Define the required variables
@@ -17,7 +26,6 @@ class SystemTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**

View File

@@ -233,7 +233,7 @@ class XmlImporterTest extends TestCase
* Test the import new option and the import new group option with repeated title.
* @test
* @covers \ProcessMaker\Importer\XmlImporter::import()
* @covers \ProcessMaker\Importer\XmlImporter::updateProcessInformation()
* @covers \ProcessMaker\Importer\Importer::updateProcessInformation()
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_try_rename_title()
{

View File

@@ -12,13 +12,22 @@ use Tests\TestCase;
*/
class AppDelayTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
/**
* Set up function.
*/
public function setUp(): void
{
parent::setUp();
$this->truncateNonInitialModels();
}
/**
@@ -41,6 +50,7 @@ class AppDelayTest extends TestCase
*/
public function it_return_scope_not_action_disable()
{
AppDelay::truncate();
$table = AppDelay::factory()->paused_foreign_keys()->create();
$this->assertCount(1, $table->notDisabled()->get());
}

Some files were not shown because too many files have changed in this diff Show More