Skip to content

Commit 9c77025

Browse files
committed
Refactor test files to improve code consistency
- Updated exception handling in PerformanceControllerExportCsvTest to use the base Exception class. - Removed unnecessary `use stdClass;` statements in PerformanceAnalysisServiceTest and added it in TableStatusCheckerTest for consistency. - Adjusted instantiation of stdClass in multiple test files for cleaner code style.
1 parent 8195e68 commit 9c77025

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

tests/Unit/Controller/PerformanceControllerExportCsvTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Nowo\PerformanceBundle\Tests\Unit\Controller;
66

7+
use Exception;
78
use Nowo\PerformanceBundle\Controller\PerformanceController;
89
use Nowo\PerformanceBundle\Repository\RouteDataRepository;
910
use Nowo\PerformanceBundle\Service\PerformanceMetricsService;
@@ -32,7 +33,7 @@ public function testExportCsvWhenGetRoutesWithAggregatesFilteredThrowsReturnsEmp
3233
{
3334
$this->metricsService
3435
->method('getRoutesWithAggregatesFiltered')
35-
->willThrowException(new \Exception('DB error'));
36+
->willThrowException(new Exception('DB error'));
3637

3738
$controller = $this->getMockBuilder(PerformanceController::class)
3839
->setConstructorArgs([

tests/Unit/Controller/PerformanceControllerStatisticsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function testStatisticsWithRequiredRolesAndIsGrantedRenders(): void
218218

219219
$envForm = $this->createMock(FormInterface::class);
220220
$envForm->method('handleRequest');
221-
$data = new \stdClass();
221+
$data = new stdClass();
222222
$data->env = 'test';
223223
$envForm->method('getData')->willReturn($data);
224224
$envForm->method('createView')->willReturn(new FormView());

tests/Unit/Service/PerformanceAnalysisServiceTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Nowo\PerformanceBundle\Model\RouteDataWithAggregates;
99
use Nowo\PerformanceBundle\Service\PerformanceAnalysisService;
1010
use PHPUnit\Framework\TestCase;
11-
use stdClass;
1211

1312
final class PerformanceAnalysisServiceTest extends TestCase
1413
{

tests/Unit/Service/TableStatusCheckerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Nowo\PerformanceBundle\Service\TableStatusChecker;
1414
use PHPUnit\Framework\TestCase;
1515
use RuntimeException;
16+
use stdClass;
1617

1718
final class TableStatusCheckerTest extends TestCase
1819
{
@@ -476,7 +477,7 @@ public function testGetRecordsTableStatusWhenAccessRecordsEnabled(): void
476477
public function testTableExistsReturnsFalseWhenRegistryReturnsNonConnection(): void
477478
{
478479
$registry = $this->createMock(ManagerRegistry::class);
479-
$registry->method('getConnection')->with('default')->willReturn(new \stdClass());
480+
$registry->method('getConnection')->with('default')->willReturn(new stdClass());
480481

481482
$checker = new TableStatusChecker($registry, 'default', 'routes_data', false);
482483

@@ -486,7 +487,7 @@ public function testTableExistsReturnsFalseWhenRegistryReturnsNonConnection(): v
486487
public function testGetMissingColumnsReturnsEmptyWhenRegistryReturnsNonConnection(): void
487488
{
488489
$registry = $this->createMock(ManagerRegistry::class);
489-
$registry->method('getConnection')->with('default')->willReturn(new \stdClass());
490+
$registry->method('getConnection')->with('default')->willReturn(new stdClass());
490491

491492
$checker = new TableStatusChecker($registry, 'default', 'routes_data', false);
492493

0 commit comments

Comments
 (0)