From f0ff183daeed25425a52f238fb40e5cf66fedaf6 Mon Sep 17 00:00:00 2001 From: Roly Gutierrez Date: Thu, 6 Feb 2025 15:16:31 -0400 Subject: [PATCH 1/2] FOUR-21803 Fix failing unit tests ## Description Tests\Feature\Api\PerformanceModelsTest::testFactories The data provider specified for Tests\Feature\Api\PerformanceModelsTest::testFactories is invalid Empty data set provided by data provider ## Solution This is a PHPUnit issue; the test is being fixed. ## Related Tickets & Packages https://processmaker.atlassian.net/browse/FOUR-21803 --- tests/Feature/Api/PerformanceModelsTest.php | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/Feature/Api/PerformanceModelsTest.php b/tests/Feature/Api/PerformanceModelsTest.php index 2e9110d9d8..ba117606c8 100644 --- a/tests/Feature/Api/PerformanceModelsTest.php +++ b/tests/Feature/Api/PerformanceModelsTest.php @@ -43,21 +43,17 @@ class PerformanceModelsTest extends TestCase */ public function FactoryListProvider() { - // TODO: fix for laravel 8 factories. This test is skipped in the trait. - return []; - - file_exists('coverage') ?: mkdir('coverage'); - $factories = app(EloquentFactory::class); - $reflection = new ReflectionObject($factories); - $property = $reflection->getProperty('definitions'); - $property->setAccessible(true); - $definitions = $property->getValue($factories); + $models = []; + $factoriesPath = app_path('Models'); + $modelFiles = glob($factoriesPath . '/*.php'); $baseTime = $this->calculateUnitTime(); - $models = []; - foreach ($definitions as $model => $definition) { - $models[] = [$model, $baseTime]; + foreach ($modelFiles as $file) { + $model = 'ProcessMaker\\Models\\' . basename($file, '.php'); + if (method_exists($model, 'factory')) { + $models[] = [$model, $baseTime]; + } } return $models; @@ -93,7 +89,7 @@ public function testFactories($model, $baseTime) $baseCount = $this->getTotalRecords(); $t = microtime(true); $times = 1; - $model->factory()->count($times)->create(); + $model::factory()->count($times)->create(); $time = microtime(true) - $t; $count = $this->getTotalRecords(); $speed = ($count - $baseCount) / ($time / $baseTime); From b014017fe7490756a10f8b6df0c9584e61f8ab76 Mon Sep 17 00:00:00 2001 From: Roly Gutierrez Date: Thu, 6 Feb 2025 16:46:58 -0400 Subject: [PATCH 2/2] FOUR-21803 Fix failing unit tests ## Description 1) Tests\Feature\Api\PerformanceRoutesTest::testRoutesSpeed The data provider specified for Tests\Feature\Api\PerformanceRoutesTest::testRoutesSpeed is invalid Undefined constant Tests\Feature\Api\PerformanceRoutesTest::endpoints /Users/user/srv/http/processmaker4/tests/Feature/Api/PerformanceRoutesTest.php:94 ## Solution This is a PHPUnit issue; the test is being fixed. ## Related Tickets & Packages https://processmaker.atlassian.net/browse/FOUR-21803 --- tests/Feature/Api/PerformanceRoutesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Api/PerformanceRoutesTest.php b/tests/Feature/Api/PerformanceRoutesTest.php index 4331a73f06..7d743162c1 100644 --- a/tests/Feature/Api/PerformanceRoutesTest.php +++ b/tests/Feature/Api/PerformanceRoutesTest.php @@ -83,7 +83,7 @@ public static function RoutesListProvider() { file_exists('coverage') ?: mkdir('coverage'); - return self::endpoints; + return self::$endpoints; } /**