From 30610195ba35e239246d1e229872bea1b004adbc Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 24 Apr 2026 10:31:00 +0200 Subject: [PATCH 01/21] fix: consider time zone during migration of orders --- .codex | 0 Repository/OrderRepository.php | 29 ++++ Service/OrderService.php | 4 + Tests/Unit/Repository/OrderRepositoryTest.php | 76 ++++++++++ Tests/Unit/Service/OrderServiceTest.php | 139 ++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 .codex create mode 100644 Tests/Unit/Repository/OrderRepositoryTest.php create mode 100644 Tests/Unit/Service/OrderServiceTest.php diff --git a/.codex b/.codex new file mode 100644 index 0000000..e69de29 diff --git a/Repository/OrderRepository.php b/Repository/OrderRepository.php index 8b7d03c..3b086fb 100644 --- a/Repository/OrderRepository.php +++ b/Repository/OrderRepository.php @@ -108,6 +108,35 @@ public function fetch($offset = 0, $limit = 250) return $query->execute()->fetchAll(); } + /** + * @return string|null + */ + public function getDatabaseTimezone() + { + try { + $timezone = $this->connection->fetchColumn( + <<<'SQL' +SELECT timeZones.timeZone +FROM ( + SELECT @@SESSION.time_zone AS timeZone + UNION + SELECT @@system_time_zone AS timeZone +) AS timeZones +WHERE timeZone != 'SYSTEM' +LIMIT 1 +SQL + ); + } catch (\Exception $e) { + return null; + } + + if (!\is_string($timezone) || $timezone === '') { + return null; + } + + return $timezone; + } + /** * @return array */ diff --git a/Service/OrderService.php b/Service/OrderService.php index 6b38f32..ea3327d 100644 --- a/Service/OrderService.php +++ b/Service/OrderService.php @@ -67,6 +67,7 @@ protected function appendAssociatedData(array $orders) $orderEsd = $this->getOrderEsd(); $orderDetails = $this->getOrderDetails(); $orderDocuments = $this->getOrderDocuments(); + $timezone = $this->orderRepository->getDatabaseTimezone(); /** @var Shop $defaultShop */ $defaultShop = $this->modelManager->getRepository(Shop::class)->getDefault(); @@ -76,6 +77,9 @@ protected function appendAssociatedData(array $orders) foreach ($orders as $key => &$order) { $order['_locale'] = $locale; + if (!empty($timezone)) { + $order['_timezone'] = $timezone; + } if (isset($orderDetails[$order['id']])) { $order['details'] = $orderDetails[$order['id']]; diff --git a/Tests/Unit/Repository/OrderRepositoryTest.php b/Tests/Unit/Repository/OrderRepositoryTest.php new file mode 100644 index 0000000..3c7dd0e --- /dev/null +++ b/Tests/Unit/Repository/OrderRepositoryTest.php @@ -0,0 +1,76 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationConnector\Tests\Unit\Repository; + +use Doctrine\DBAL\Connection; +use PHPUnit\Framework\TestCase; +use SwagMigrationConnector\Repository\OrderRepository; + +require_once \dirname(__DIR__, 3) . '/Repository/ApiRepositoryInterface.php'; +require_once \dirname(__DIR__, 3) . '/Repository/AbstractRepository.php'; +require_once \dirname(__DIR__, 3) . '/Repository/OrderRepository.php'; + +class OrderRepositoryTest extends TestCase +{ + /** + * @return void + */ + public function testGetDatabaseTimezoneReturnsTimezoneFromConnection() + { + $connection = $this->getMockBuilder(Connection::class) + ->disableOriginalConstructor() + ->onlyMethods(['fetchColumn']) + ->getMock(); + + $connection->expects(static::once()) + ->method('fetchColumn') + ->willReturn('Europe/Berlin'); + + $repository = new OrderRepository($connection); + + static::assertSame('Europe/Berlin', $repository->getDatabaseTimezone()); + } + + /** + * @return void + */ + public function testGetDatabaseTimezoneReturnsNullOnConnectionFailure() + { + $connection = $this->getMockBuilder(Connection::class) + ->disableOriginalConstructor() + ->onlyMethods(['fetchColumn']) + ->getMock(); + + $connection->expects(static::once()) + ->method('fetchColumn') + ->willThrowException(new \Exception('Connection failed')); + + $repository = new OrderRepository($connection); + + static::assertNull($repository->getDatabaseTimezone()); + } + + /** + * @return void + */ + public function testGetDatabaseTimezoneReturnsNullForEmptyStrings() + { + $connection = $this->getMockBuilder(Connection::class) + ->disableOriginalConstructor() + ->onlyMethods(['fetchColumn']) + ->getMock(); + + $connection->expects(static::once()) + ->method('fetchColumn') + ->willReturn(''); + + $repository = new OrderRepository($connection); + + static::assertNull($repository->getDatabaseTimezone()); + } +} diff --git a/Tests/Unit/Service/OrderServiceTest.php b/Tests/Unit/Service/OrderServiceTest.php new file mode 100644 index 0000000..addae95 --- /dev/null +++ b/Tests/Unit/Service/OrderServiceTest.php @@ -0,0 +1,139 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationConnector\Tests\Unit\Service; + +use PHPUnit\Framework\TestCase; +use Shopware\Components\Model\ModelManager; +use Shopware\Models\Shop\Locale; +use Shopware\Models\Shop\Shop; +use SwagMigrationConnector\Repository\OrderRepository; +use SwagMigrationConnector\Service\OrderService; + +require_once \dirname(__DIR__, 3) . '/Repository/ApiRepositoryInterface.php'; +require_once \dirname(__DIR__, 3) . '/Repository/AbstractRepository.php'; +require_once \dirname(__DIR__, 3) . '/Repository/OrderRepository.php'; +require_once \dirname(__DIR__, 3) . '/Service/AbstractApiService.php'; +require_once \dirname(__DIR__, 3) . '/Service/OrderService.php'; + +class OrderServiceTest extends TestCase +{ + /** + * @return void + */ + public function testGetOrdersAddsDatabaseTimezoneToEveryOrder() + { + $orderService = $this->createOrderService('Europe/Berlin', [ + ['ordering.id' => '15'], + ['ordering.id' => '57'], + ], 2); + + $orders = $orderService->getOrders(0, 2); + + static::assertCount(2, $orders); + static::assertSame('Europe/Berlin', $orders[0]['_timezone']); + static::assertSame('Europe/Berlin', $orders[1]['_timezone']); + static::assertSame('en-GB', $orders[0]['_locale']); + } + + /** + * @return void + */ + public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable() + { + $orderService = $this->createOrderService(null, [ + ['ordering.id' => '15'], + ], 1); + + $orders = $orderService->getOrders(0, 1); + + static::assertCount(1, $orders); + static::assertArrayNotHasKey('_timezone', $orders[0]); + static::assertSame('en-GB', $orders[0]['_locale']); + } + + /** + * @param string|null $timezone + * @param array $fetchedOrders + * @param int $limit + * + * @return OrderService + */ + private function createOrderService($timezone, array $fetchedOrders, $limit) + { + $orderIds = \array_column($fetchedOrders, 'ordering.id'); + $orderRepository = $this->getMockBuilder(OrderRepository::class) + ->disableOriginalConstructor() + ->onlyMethods([ + 'fetch', + 'fetchOrderDetails', + 'fetchOrderEsd', + 'getEsdConfig', + 'fetchOrderDocuments', + 'getDatabaseTimezone', + ]) + ->getMock(); + + $orderRepository->expects(static::once()) + ->method('fetch') + ->with(0, $limit) + ->willReturn($fetchedOrders); + $orderRepository->expects(static::once()) + ->method('fetchOrderDetails') + ->with($orderIds) + ->willReturn([]); + $orderRepository->expects(static::once()) + ->method('fetchOrderEsd') + ->with($orderIds) + ->willReturn([]); + $orderRepository->expects(static::once()) + ->method('getEsdConfig') + ->willReturn(null); + $orderRepository->expects(static::once()) + ->method('fetchOrderDocuments') + ->with($orderIds) + ->willReturn([]); + $orderRepository->expects(static::once()) + ->method('getDatabaseTimezone') + ->willReturn($timezone); + + $shopRepository = $this->getMockBuilder(\stdClass::class) + ->addMethods(['getDefault']) + ->getMock(); + $shopRepository->expects(static::once()) + ->method('getDefault') + ->willReturn($this->createDefaultShop()); + + $modelManager = $this->getMockBuilder(ModelManager::class) + ->disableOriginalConstructor() + ->getMock(); + + $modelManager->expects(static::once()) + ->method('getRepository') + ->with(Shop::class) + ->willReturn($shopRepository); + + return new OrderService( + $orderRepository, + $modelManager + ); + } + + /** + * @return Shop + */ + private function createDefaultShop() + { + $locale = new Locale(); + $locale->setLocale('en_GB'); + + $shop = new Shop(); + $shop->setLocale($locale); + + return $shop; + } +} From 83296569cb14aafd79fd04d235b1a00dbefe782b Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 24 Apr 2026 10:39:01 +0200 Subject: [PATCH 02/21] fix tests --- Tests/Unit/Repository/OrderRepositoryTest.php | 4 ---- Tests/Unit/Service/OrderServiceTest.php | 6 ------ 2 files changed, 10 deletions(-) diff --git a/Tests/Unit/Repository/OrderRepositoryTest.php b/Tests/Unit/Repository/OrderRepositoryTest.php index 3c7dd0e..389ece8 100644 --- a/Tests/Unit/Repository/OrderRepositoryTest.php +++ b/Tests/Unit/Repository/OrderRepositoryTest.php @@ -11,10 +11,6 @@ use PHPUnit\Framework\TestCase; use SwagMigrationConnector\Repository\OrderRepository; -require_once \dirname(__DIR__, 3) . '/Repository/ApiRepositoryInterface.php'; -require_once \dirname(__DIR__, 3) . '/Repository/AbstractRepository.php'; -require_once \dirname(__DIR__, 3) . '/Repository/OrderRepository.php'; - class OrderRepositoryTest extends TestCase { /** diff --git a/Tests/Unit/Service/OrderServiceTest.php b/Tests/Unit/Service/OrderServiceTest.php index addae95..ba1c5ed 100644 --- a/Tests/Unit/Service/OrderServiceTest.php +++ b/Tests/Unit/Service/OrderServiceTest.php @@ -14,12 +14,6 @@ use SwagMigrationConnector\Repository\OrderRepository; use SwagMigrationConnector\Service\OrderService; -require_once \dirname(__DIR__, 3) . '/Repository/ApiRepositoryInterface.php'; -require_once \dirname(__DIR__, 3) . '/Repository/AbstractRepository.php'; -require_once \dirname(__DIR__, 3) . '/Repository/OrderRepository.php'; -require_once \dirname(__DIR__, 3) . '/Service/AbstractApiService.php'; -require_once \dirname(__DIR__, 3) . '/Service/OrderService.php'; - class OrderServiceTest extends TestCase { /** From 86c2bf8f8e93f90d189cdf129c4939896df286ae Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 24 Apr 2026 10:44:21 +0200 Subject: [PATCH 03/21] fix cs --- Tests/Unit/Service/OrderServiceTest.php | 29 ++++++++----------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/Tests/Unit/Service/OrderServiceTest.php b/Tests/Unit/Service/OrderServiceTest.php index ba1c5ed..e19f7cb 100644 --- a/Tests/Unit/Service/OrderServiceTest.php +++ b/Tests/Unit/Service/OrderServiceTest.php @@ -10,16 +10,14 @@ use PHPUnit\Framework\TestCase; use Shopware\Components\Model\ModelManager; use Shopware\Models\Shop\Locale; +use Shopware\Models\Shop\Repository as ShopRepository; use Shopware\Models\Shop\Shop; use SwagMigrationConnector\Repository\OrderRepository; use SwagMigrationConnector\Service\OrderService; class OrderServiceTest extends TestCase { - /** - * @return void - */ - public function testGetOrdersAddsDatabaseTimezoneToEveryOrder() + public function testGetOrdersAddsDatabaseTimezoneToEveryOrder(): void { $orderService = $this->createOrderService('Europe/Berlin', [ ['ordering.id' => '15'], @@ -34,10 +32,7 @@ public function testGetOrdersAddsDatabaseTimezoneToEveryOrder() static::assertSame('en-GB', $orders[0]['_locale']); } - /** - * @return void - */ - public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable() + public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable(): void { $orderService = $this->createOrderService(null, [ ['ordering.id' => '15'], @@ -51,13 +46,9 @@ public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable() } /** - * @param string|null $timezone - * @param array $fetchedOrders - * @param int $limit - * - * @return OrderService + * @param list $fetchedOrders */ - private function createOrderService($timezone, array $fetchedOrders, $limit) + private function createOrderService(?string $timezone, array $fetchedOrders, int $limit): OrderService { $orderIds = \array_column($fetchedOrders, 'ordering.id'); $orderRepository = $this->getMockBuilder(OrderRepository::class) @@ -95,8 +86,9 @@ private function createOrderService($timezone, array $fetchedOrders, $limit) ->method('getDatabaseTimezone') ->willReturn($timezone); - $shopRepository = $this->getMockBuilder(\stdClass::class) - ->addMethods(['getDefault']) + $shopRepository = $this->getMockBuilder(ShopRepository::class) + ->disableOriginalConstructor() + ->onlyMethods(['getDefault']) ->getMock(); $shopRepository->expects(static::once()) ->method('getDefault') @@ -117,10 +109,7 @@ private function createOrderService($timezone, array $fetchedOrders, $limit) ); } - /** - * @return Shop - */ - private function createDefaultShop() + private function createDefaultShop(): Shop { $locale = new Locale(); $locale->setLocale('en_GB'); From d1af9e7edafb4a40fea19bfff5e7b0777fa2c4e7 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 24 Apr 2026 10:50:56 +0200 Subject: [PATCH 04/21] fix test --- Tests/Unit/Repository/OrderRepositoryTest.php | 6 ++--- Tests/Unit/Service/OrderServiceTest.php | 25 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Tests/Unit/Repository/OrderRepositoryTest.php b/Tests/Unit/Repository/OrderRepositoryTest.php index 389ece8..9c94d5e 100644 --- a/Tests/Unit/Repository/OrderRepositoryTest.php +++ b/Tests/Unit/Repository/OrderRepositoryTest.php @@ -20,7 +20,7 @@ public function testGetDatabaseTimezoneReturnsTimezoneFromConnection() { $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() - ->onlyMethods(['fetchColumn']) + ->setMethods(['fetchColumn']) ->getMock(); $connection->expects(static::once()) @@ -39,7 +39,7 @@ public function testGetDatabaseTimezoneReturnsNullOnConnectionFailure() { $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() - ->onlyMethods(['fetchColumn']) + ->setMethods(['fetchColumn']) ->getMock(); $connection->expects(static::once()) @@ -58,7 +58,7 @@ public function testGetDatabaseTimezoneReturnsNullForEmptyStrings() { $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() - ->onlyMethods(['fetchColumn']) + ->setMethods(['fetchColumn']) ->getMock(); $connection->expects(static::once()) diff --git a/Tests/Unit/Service/OrderServiceTest.php b/Tests/Unit/Service/OrderServiceTest.php index e19f7cb..4be45fb 100644 --- a/Tests/Unit/Service/OrderServiceTest.php +++ b/Tests/Unit/Service/OrderServiceTest.php @@ -17,7 +17,10 @@ class OrderServiceTest extends TestCase { - public function testGetOrdersAddsDatabaseTimezoneToEveryOrder(): void + /** + * @return void + */ + public function testGetOrdersAddsDatabaseTimezoneToEveryOrder() { $orderService = $this->createOrderService('Europe/Berlin', [ ['ordering.id' => '15'], @@ -32,7 +35,10 @@ public function testGetOrdersAddsDatabaseTimezoneToEveryOrder(): void static::assertSame('en-GB', $orders[0]['_locale']); } - public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable(): void + /** + * @return void + */ + public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable() { $orderService = $this->createOrderService(null, [ ['ordering.id' => '15'], @@ -46,14 +52,18 @@ public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable(): void } /** + * @param string|null $timezone * @param list $fetchedOrders + * @param int $limit + * + * @return OrderService */ - private function createOrderService(?string $timezone, array $fetchedOrders, int $limit): OrderService + private function createOrderService($timezone, array $fetchedOrders, $limit) { $orderIds = \array_column($fetchedOrders, 'ordering.id'); $orderRepository = $this->getMockBuilder(OrderRepository::class) ->disableOriginalConstructor() - ->onlyMethods([ + ->setMethods([ 'fetch', 'fetchOrderDetails', 'fetchOrderEsd', @@ -88,7 +98,7 @@ private function createOrderService(?string $timezone, array $fetchedOrders, int $shopRepository = $this->getMockBuilder(ShopRepository::class) ->disableOriginalConstructor() - ->onlyMethods(['getDefault']) + ->setMethods(['getDefault']) ->getMock(); $shopRepository->expects(static::once()) ->method('getDefault') @@ -109,7 +119,10 @@ private function createOrderService(?string $timezone, array $fetchedOrders, int ); } - private function createDefaultShop(): Shop + /** + * @return Shop + */ + private function createDefaultShop() { $locale = new Locale(); $locale->setLocale('en_GB'); From df60eeb1b567b2811b4259f01043ae87b885b730 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 24 Apr 2026 11:15:00 +0200 Subject: [PATCH 05/21] remove codex file --- .codex | 0 .gitignore | 1 + 2 files changed, 1 insertion(+) delete mode 100644 .codex diff --git a/.codex b/.codex deleted file mode 100644 index e69de29..0000000 diff --git a/.gitignore b/.gitignore index f878d41..eb04423 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Thumbs.db vendor .phpunit.result.cache .php-cs-fixer.cache +.codex \ No newline at end of file From cc2ad16848a5eecc7e00f3239e1f09e552a76854 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Mon, 4 May 2026 10:34:03 +0200 Subject: [PATCH 06/21] Read timezone from config --- Controllers/Api/SwagMigrationTimeZone.php | 22 +++++ Repository/OrderRepository.php | 29 ------- .../Controllers/SwagMigrationTimeZoneTest.php | 81 +++++++++++++++++++ Tests/Unit/Repository/OrderRepositoryTest.php | 72 ----------------- 4 files changed, 103 insertions(+), 101 deletions(-) create mode 100644 Controllers/Api/SwagMigrationTimeZone.php create mode 100644 Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php delete mode 100644 Tests/Unit/Repository/OrderRepositoryTest.php diff --git a/Controllers/Api/SwagMigrationTimeZone.php b/Controllers/Api/SwagMigrationTimeZone.php new file mode 100644 index 0000000..91869a1 --- /dev/null +++ b/Controllers/Api/SwagMigrationTimeZone.php @@ -0,0 +1,22 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use SwagMigrationConnector\Controllers\SwagMigrationApiControllerBase; +use SwagMigrationConnector\Service\ControllerReturnStruct; + +class Shopware_Controllers_Api_SwagMigrationTimeZone extends SwagMigrationApiControllerBase +{ + public function indexAction() + { + $timeZone = (string) $this->container->getParameter('shopware.db.timezone'); + if ($timeZone === '') { + $timeZone = null; + } + + $this->view->assign((new ControllerReturnStruct(['timezone' => $timeZone]))->jsonSerialize()); + } +} diff --git a/Repository/OrderRepository.php b/Repository/OrderRepository.php index 3b086fb..8b7d03c 100644 --- a/Repository/OrderRepository.php +++ b/Repository/OrderRepository.php @@ -108,35 +108,6 @@ public function fetch($offset = 0, $limit = 250) return $query->execute()->fetchAll(); } - /** - * @return string|null - */ - public function getDatabaseTimezone() - { - try { - $timezone = $this->connection->fetchColumn( - <<<'SQL' -SELECT timeZones.timeZone -FROM ( - SELECT @@SESSION.time_zone AS timeZone - UNION - SELECT @@system_time_zone AS timeZone -) AS timeZones -WHERE timeZone != 'SYSTEM' -LIMIT 1 -SQL - ); - } catch (\Exception $e) { - return null; - } - - if (!\is_string($timezone) || $timezone === '') { - return null; - } - - return $timezone; - } - /** * @return array */ diff --git a/Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php new file mode 100644 index 0000000..90d26e2 --- /dev/null +++ b/Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php @@ -0,0 +1,81 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationConnector\Tests\Functional\Controllers; + +use Enlight_Controller_Request_RequestTestCase as Request; +use Enlight_Controller_Response_ResponseTestCase as Response; +use Enlight_Template_Manager; +use Enlight_View_Default; +use PHPUnit\Framework\TestCase; +use Shopware\Components\DependencyInjection\Container; + +require __DIR__ . '/../../../Controllers/Api/SwagMigrationTimeZone.php'; + +class SwagMigrationTimeZoneTest extends TestCase +{ + /** + * @dataProvider getDifferentTimeZones + * + * @return void + */ + public function testIndexActionReturnsConfiguredDatabaseTimeZone($timezone, $expectedTimezone) + { + $controller = $this->createController($timezone); + + $controller->indexAction(); + + $assign = $controller->View()->getAssign(); + + static::assertSame(['timezone' => $expectedTimezone], $assign['data']); + } + + public function getDifferentTimeZones(): array + { + return [ + 'empty' => [ + 'timezone' => '', + 'expectedTimezone' => null, + ], + 'NULL' => [ + 'timezone' => NULL, + 'expectedTimezone' => NULL, + ], + 'Europe/Berlin' => [ + 'timezone' => 'Europe/Berlin', + 'expectedTimezone' => 'Europe/Berlin', + ], + 'Europe/London' => [ + 'timezone' => 'Europe/London', + 'expectedTimezone' => 'Europe/London', + ], + 'America/New_York' => [ + 'timezone' => 'America/New_York', + 'expectedTimezone' => 'America/New_York', + ], + ]; + } + + /** + * @param string|null $timeZone + * + * @return \Shopware_Controllers_Api_SwagMigrationTimeZone + */ + private function createController($timeZone) + { + $container = new Container(); + $container->setParameter('shopware.db.timezone', $timeZone); + + $controller = new \Shopware_Controllers_Api_SwagMigrationTimeZone(); + $controller->setRequest(new Request()); + $controller->setResponse(new Response()); + $controller->setView(new Enlight_View_Default(new Enlight_Template_Manager())); + $controller->setContainer($container); + + return $controller; + } +} diff --git a/Tests/Unit/Repository/OrderRepositoryTest.php b/Tests/Unit/Repository/OrderRepositoryTest.php deleted file mode 100644 index 9c94d5e..0000000 --- a/Tests/Unit/Repository/OrderRepositoryTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationConnector\Tests\Unit\Repository; - -use Doctrine\DBAL\Connection; -use PHPUnit\Framework\TestCase; -use SwagMigrationConnector\Repository\OrderRepository; - -class OrderRepositoryTest extends TestCase -{ - /** - * @return void - */ - public function testGetDatabaseTimezoneReturnsTimezoneFromConnection() - { - $connection = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() - ->setMethods(['fetchColumn']) - ->getMock(); - - $connection->expects(static::once()) - ->method('fetchColumn') - ->willReturn('Europe/Berlin'); - - $repository = new OrderRepository($connection); - - static::assertSame('Europe/Berlin', $repository->getDatabaseTimezone()); - } - - /** - * @return void - */ - public function testGetDatabaseTimezoneReturnsNullOnConnectionFailure() - { - $connection = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() - ->setMethods(['fetchColumn']) - ->getMock(); - - $connection->expects(static::once()) - ->method('fetchColumn') - ->willThrowException(new \Exception('Connection failed')); - - $repository = new OrderRepository($connection); - - static::assertNull($repository->getDatabaseTimezone()); - } - - /** - * @return void - */ - public function testGetDatabaseTimezoneReturnsNullForEmptyStrings() - { - $connection = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() - ->setMethods(['fetchColumn']) - ->getMock(); - - $connection->expects(static::once()) - ->method('fetchColumn') - ->willReturn(''); - - $repository = new OrderRepository($connection); - - static::assertNull($repository->getDatabaseTimezone()); - } -} From 49bf3839e0e192c09bd66768daffffe5cfae24cc Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Wed, 6 May 2026 15:39:03 +0200 Subject: [PATCH 07/21] switch timezone information to environment reader --- Controllers/Api/SwagMigrationTimeZone.php | 22 -- Resources/services.xml | 1 + Service/EnvironmentService.php | 11 +- .../Controllers/SwagMigrationTimeZoneTest.php | 81 ------- Tests/Unit/Service/EnvironmentServiceTest.php | 213 ++++++++++++++++++ 5 files changed, 224 insertions(+), 104 deletions(-) delete mode 100644 Controllers/Api/SwagMigrationTimeZone.php delete mode 100644 Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php create mode 100644 Tests/Unit/Service/EnvironmentServiceTest.php diff --git a/Controllers/Api/SwagMigrationTimeZone.php b/Controllers/Api/SwagMigrationTimeZone.php deleted file mode 100644 index 91869a1..0000000 --- a/Controllers/Api/SwagMigrationTimeZone.php +++ /dev/null @@ -1,22 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use SwagMigrationConnector\Controllers\SwagMigrationApiControllerBase; -use SwagMigrationConnector\Service\ControllerReturnStruct; - -class Shopware_Controllers_Api_SwagMigrationTimeZone extends SwagMigrationApiControllerBase -{ - public function indexAction() - { - $timeZone = (string) $this->container->getParameter('shopware.db.timezone'); - if ($timeZone === '') { - $timeZone = null; - } - - $this->view->assign((new ControllerReturnStruct(['timezone' => $timeZone]))->jsonSerialize()); - } -} diff --git a/Resources/services.xml b/Resources/services.xml index e49030d..96f3b60 100644 --- a/Resources/services.xml +++ b/Resources/services.xml @@ -15,6 +15,7 @@ %shopware.release.version% %shopware.release.version_text% %shopware.release.revision% + %shopware.db.timezone% diff --git a/Service/EnvironmentService.php b/Service/EnvironmentService.php index 1c1d643..b325d96 100644 --- a/Service/EnvironmentService.php +++ b/Service/EnvironmentService.php @@ -50,10 +50,16 @@ class EnvironmentService extends AbstractApiService */ private $revision; + /** + * @var string|null + */ + private $timezone; + /** * @param string $version * @param string $versionText * @param string $revision + * @param string|null $timezone */ public function __construct( ModelManager $modelManager, @@ -62,7 +68,8 @@ public function __construct( PluginInformationService $pluginInformationService, $version, $versionText, - $revision + $revision, + $timezone ) { $this->modelManager = $modelManager; $this->environmentRepository = $environmentRepository; @@ -71,6 +78,7 @@ public function __construct( $this->version = $version; $this->versionText = $versionText; $this->revision = $revision; + $this->timezone = $timezone === '' ? null : $timezone; } /** @@ -100,6 +108,7 @@ public function getEnvironmentInformation() 'additionalData' => $this->getAdditionalData(), 'updateAvailable' => $this->pluginInformationService->isUpdateRequired($locale), 'config' => $config, + 'timezone' => $this->timezone, ]; return $resultSet; diff --git a/Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php deleted file mode 100644 index 90d26e2..0000000 --- a/Tests/Functional/Controllers/SwagMigrationTimeZoneTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationConnector\Tests\Functional\Controllers; - -use Enlight_Controller_Request_RequestTestCase as Request; -use Enlight_Controller_Response_ResponseTestCase as Response; -use Enlight_Template_Manager; -use Enlight_View_Default; -use PHPUnit\Framework\TestCase; -use Shopware\Components\DependencyInjection\Container; - -require __DIR__ . '/../../../Controllers/Api/SwagMigrationTimeZone.php'; - -class SwagMigrationTimeZoneTest extends TestCase -{ - /** - * @dataProvider getDifferentTimeZones - * - * @return void - */ - public function testIndexActionReturnsConfiguredDatabaseTimeZone($timezone, $expectedTimezone) - { - $controller = $this->createController($timezone); - - $controller->indexAction(); - - $assign = $controller->View()->getAssign(); - - static::assertSame(['timezone' => $expectedTimezone], $assign['data']); - } - - public function getDifferentTimeZones(): array - { - return [ - 'empty' => [ - 'timezone' => '', - 'expectedTimezone' => null, - ], - 'NULL' => [ - 'timezone' => NULL, - 'expectedTimezone' => NULL, - ], - 'Europe/Berlin' => [ - 'timezone' => 'Europe/Berlin', - 'expectedTimezone' => 'Europe/Berlin', - ], - 'Europe/London' => [ - 'timezone' => 'Europe/London', - 'expectedTimezone' => 'Europe/London', - ], - 'America/New_York' => [ - 'timezone' => 'America/New_York', - 'expectedTimezone' => 'America/New_York', - ], - ]; - } - - /** - * @param string|null $timeZone - * - * @return \Shopware_Controllers_Api_SwagMigrationTimeZone - */ - private function createController($timeZone) - { - $container = new Container(); - $container->setParameter('shopware.db.timezone', $timeZone); - - $controller = new \Shopware_Controllers_Api_SwagMigrationTimeZone(); - $controller->setRequest(new Request()); - $controller->setResponse(new Response()); - $controller->setView(new Enlight_View_Default(new Enlight_Template_Manager())); - $controller->setContainer($container); - - return $controller; - } -} diff --git a/Tests/Unit/Service/EnvironmentServiceTest.php b/Tests/Unit/Service/EnvironmentServiceTest.php new file mode 100644 index 0000000..4285314 --- /dev/null +++ b/Tests/Unit/Service/EnvironmentServiceTest.php @@ -0,0 +1,213 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationConnector\Tests\Unit\Service; + +use Doctrine\ORM\EntityRepository; +use PHPUnit\Framework\TestCase; +use Shopware\Components\Model\ModelManager; +use Shopware\Models\Shop\Currency; +use Shopware\Models\Shop\Locale; +use Shopware\Models\Shop\Repository as ShopRepository; +use Shopware\Models\Shop\Shop; +use SwagMigrationConnector\Repository\ConfigRepository; +use SwagMigrationConnector\Repository\EnvironmentRepository; +use SwagMigrationConnector\Service\EnvironmentService; +use SwagMigrationConnector\Service\PluginInformationService; + +class EnvironmentServiceTest extends TestCase +{ + /** + * @dataProvider getDifferentTimeZones + * + * @param string|null $timezone + * @param string|null $expectedTimezone + * + * @return void + */ + public function testGetEnvironmentInformationReturnsDatabaseTimezone($timezone, $expectedTimezone) + { + $environmentService = $this->createEnvironmentService($timezone); + + $environmentInformation = $environmentService->getEnvironmentInformation(); + + static::assertArrayHasKey('timezone', $environmentInformation); + static::assertSame($expectedTimezone, $environmentInformation['timezone']); + } + + public function getDifferentTimeZones(): array + { + return [ + 'null' => [ + 'timezone' => null, + 'expectedTimezone' => null, + ], + 'empty' => [ + 'timezone' => '', + 'expectedTimezone' => null, + ], + 'Europe/Berlin' => [ + 'timezone' => 'Europe/Berlin', + 'expectedTimezone' => 'Europe/Berlin', + ], + 'Europe/London' => [ + 'timezone' => 'Europe/London', + 'expectedTimezone' => 'Europe/London', + ], + ]; + } + + /** + * @param string|null $timezone + * + * @return EnvironmentService + */ + private function createEnvironmentService($timezone) + { + return new EnvironmentService( + $this->createModelManager(), + $this->createEnvironmentRepository(), + $this->createConfigRepository(), + $this->createPluginInformationService(), + '5.7.20', + 'Shopware 5.7.20', + 'test-revision', + $timezone + ); + } + + /** + * @return ModelManager + */ + private function createModelManager() + { + $modelManager = $this->getMockBuilder(ModelManager::class) + ->disableOriginalConstructor() + ->getMock(); + + $modelManager->expects(static::exactly(2)) + ->method('getRepository') + ->willReturnMap([ + [Shop::class, $this->createShopRepository()], + [Currency::class, $this->createCurrencyRepository()], + ]); + + return $modelManager; + } + + /** + * @return ShopRepository + */ + private function createShopRepository() + { + $shopRepository = $this->getMockBuilder(ShopRepository::class) + ->disableOriginalConstructor() + ->setMethods(['getDefault']) + ->getMock(); + + $shopRepository->expects(static::once()) + ->method('getDefault') + ->willReturn($this->createDefaultShop()); + + return $shopRepository; + } + + /** + * @return EntityRepository + */ + private function createCurrencyRepository() + { + $currencyRepository = $this->getMockBuilder(EntityRepository::class) + ->disableOriginalConstructor() + ->setMethods(['findOneBy']) + ->getMock(); + + $currencyRepository->expects(static::once()) + ->method('findOneBy') + ->with(['default' => 1]) + ->willReturn($this->createDefaultCurrency()); + + return $currencyRepository; + } + + /** + * @return EnvironmentRepository + */ + private function createEnvironmentRepository() + { + $environmentRepository = $this->getMockBuilder(EnvironmentRepository::class) + ->disableOriginalConstructor() + ->setMethods(['getShops']) + ->getMock(); + + $environmentRepository->expects(static::once()) + ->method('getShops') + ->willReturn([]); + + return $environmentRepository; + } + + /** + * @return ConfigRepository + */ + private function createConfigRepository() + { + $configRepository = $this->getMockBuilder(ConfigRepository::class) + ->disableOriginalConstructor() + ->setMethods(['fetch']) + ->getMock(); + + $configRepository->expects(static::once()) + ->method('fetch') + ->willReturn([]); + + return $configRepository; + } + + /** + * @return PluginInformationService + */ + private function createPluginInformationService() + { + $pluginInformationService = $this->getMockBuilder(PluginInformationService::class) + ->disableOriginalConstructor() + ->setMethods(['isUpdateRequired']) + ->getMock(); + + $pluginInformationService->expects(static::once()) + ->method('isUpdateRequired') + ->with('en-GB') + ->willReturn(false); + + return $pluginInformationService; + } + + /** + * @return Shop + */ + private function createDefaultShop() + { + $locale = new Locale(); + $locale->setLocale('en_GB'); + + $shop = new Shop(); + $shop->setLocale($locale); + + return $shop; + } + + /** + * @return Currency + */ + private function createDefaultCurrency() + { + $currency = new Currency(); + $currency->setCurrency('EUR'); + + return $currency; + } +} From 07e8d356b032e952253ce62d2c2da98f466e7283 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Wed, 6 May 2026 15:58:08 +0200 Subject: [PATCH 08/21] Fix phpstan and remove unused test file --- Service/OrderService.php | 4 - Tests/Unit/Service/EnvironmentServiceTest.php | 5 +- Tests/Unit/Service/OrderServiceTest.php | 135 ------------------ 3 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 Tests/Unit/Service/OrderServiceTest.php diff --git a/Service/OrderService.php b/Service/OrderService.php index ea3327d..6b38f32 100644 --- a/Service/OrderService.php +++ b/Service/OrderService.php @@ -67,7 +67,6 @@ protected function appendAssociatedData(array $orders) $orderEsd = $this->getOrderEsd(); $orderDetails = $this->getOrderDetails(); $orderDocuments = $this->getOrderDocuments(); - $timezone = $this->orderRepository->getDatabaseTimezone(); /** @var Shop $defaultShop */ $defaultShop = $this->modelManager->getRepository(Shop::class)->getDefault(); @@ -77,9 +76,6 @@ protected function appendAssociatedData(array $orders) foreach ($orders as $key => &$order) { $order['_locale'] = $locale; - if (!empty($timezone)) { - $order['_timezone'] = $timezone; - } if (isset($orderDetails[$order['id']])) { $order['details'] = $orderDetails[$order['id']]; diff --git a/Tests/Unit/Service/EnvironmentServiceTest.php b/Tests/Unit/Service/EnvironmentServiceTest.php index 4285314..d97277e 100644 --- a/Tests/Unit/Service/EnvironmentServiceTest.php +++ b/Tests/Unit/Service/EnvironmentServiceTest.php @@ -39,6 +39,9 @@ public function testGetEnvironmentInformationReturnsDatabaseTimezone($timezone, static::assertSame($expectedTimezone, $environmentInformation['timezone']); } + /** + * @return array + */ public function getDifferentTimeZones(): array { return [ @@ -117,7 +120,7 @@ private function createShopRepository() } /** - * @return EntityRepository + * @return EntityRepository */ private function createCurrencyRepository() { diff --git a/Tests/Unit/Service/OrderServiceTest.php b/Tests/Unit/Service/OrderServiceTest.php deleted file mode 100644 index 4be45fb..0000000 --- a/Tests/Unit/Service/OrderServiceTest.php +++ /dev/null @@ -1,135 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationConnector\Tests\Unit\Service; - -use PHPUnit\Framework\TestCase; -use Shopware\Components\Model\ModelManager; -use Shopware\Models\Shop\Locale; -use Shopware\Models\Shop\Repository as ShopRepository; -use Shopware\Models\Shop\Shop; -use SwagMigrationConnector\Repository\OrderRepository; -use SwagMigrationConnector\Service\OrderService; - -class OrderServiceTest extends TestCase -{ - /** - * @return void - */ - public function testGetOrdersAddsDatabaseTimezoneToEveryOrder() - { - $orderService = $this->createOrderService('Europe/Berlin', [ - ['ordering.id' => '15'], - ['ordering.id' => '57'], - ], 2); - - $orders = $orderService->getOrders(0, 2); - - static::assertCount(2, $orders); - static::assertSame('Europe/Berlin', $orders[0]['_timezone']); - static::assertSame('Europe/Berlin', $orders[1]['_timezone']); - static::assertSame('en-GB', $orders[0]['_locale']); - } - - /** - * @return void - */ - public function testGetOrdersOmitsDatabaseTimezoneWhenUnavailable() - { - $orderService = $this->createOrderService(null, [ - ['ordering.id' => '15'], - ], 1); - - $orders = $orderService->getOrders(0, 1); - - static::assertCount(1, $orders); - static::assertArrayNotHasKey('_timezone', $orders[0]); - static::assertSame('en-GB', $orders[0]['_locale']); - } - - /** - * @param string|null $timezone - * @param list $fetchedOrders - * @param int $limit - * - * @return OrderService - */ - private function createOrderService($timezone, array $fetchedOrders, $limit) - { - $orderIds = \array_column($fetchedOrders, 'ordering.id'); - $orderRepository = $this->getMockBuilder(OrderRepository::class) - ->disableOriginalConstructor() - ->setMethods([ - 'fetch', - 'fetchOrderDetails', - 'fetchOrderEsd', - 'getEsdConfig', - 'fetchOrderDocuments', - 'getDatabaseTimezone', - ]) - ->getMock(); - - $orderRepository->expects(static::once()) - ->method('fetch') - ->with(0, $limit) - ->willReturn($fetchedOrders); - $orderRepository->expects(static::once()) - ->method('fetchOrderDetails') - ->with($orderIds) - ->willReturn([]); - $orderRepository->expects(static::once()) - ->method('fetchOrderEsd') - ->with($orderIds) - ->willReturn([]); - $orderRepository->expects(static::once()) - ->method('getEsdConfig') - ->willReturn(null); - $orderRepository->expects(static::once()) - ->method('fetchOrderDocuments') - ->with($orderIds) - ->willReturn([]); - $orderRepository->expects(static::once()) - ->method('getDatabaseTimezone') - ->willReturn($timezone); - - $shopRepository = $this->getMockBuilder(ShopRepository::class) - ->disableOriginalConstructor() - ->setMethods(['getDefault']) - ->getMock(); - $shopRepository->expects(static::once()) - ->method('getDefault') - ->willReturn($this->createDefaultShop()); - - $modelManager = $this->getMockBuilder(ModelManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $modelManager->expects(static::once()) - ->method('getRepository') - ->with(Shop::class) - ->willReturn($shopRepository); - - return new OrderService( - $orderRepository, - $modelManager - ); - } - - /** - * @return Shop - */ - private function createDefaultShop() - { - $locale = new Locale(); - $locale->setLocale('en_GB'); - - $shop = new Shop(); - $shop->setLocale($locale); - - return $shop; - } -} From 6b5121f2693204e9776f57dd9b8d508f12c508af Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 8 May 2026 08:12:47 +0200 Subject: [PATCH 09/21] Fix tests --- Resources/services.xml | 2 +- Service/EnvironmentService.php | 17 ++++++---- Tests/Unit/Service/EnvironmentServiceTest.php | 32 +++++++++++-------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Resources/services.xml b/Resources/services.xml index 96f3b60..bdcfcf7 100644 --- a/Resources/services.xml +++ b/Resources/services.xml @@ -15,7 +15,7 @@ %shopware.release.version% %shopware.release.version_text% %shopware.release.revision% - %shopware.db.timezone% + %shopware.db% diff --git a/Service/EnvironmentService.php b/Service/EnvironmentService.php index b325d96..43e4dfd 100644 --- a/Service/EnvironmentService.php +++ b/Service/EnvironmentService.php @@ -15,6 +15,8 @@ class EnvironmentService extends AbstractApiService { + public const TIMEZONE_KEY = 'timezone'; + /** * @var ModelManager */ @@ -56,10 +58,7 @@ class EnvironmentService extends AbstractApiService private $timezone; /** - * @param string $version - * @param string $versionText - * @param string $revision - * @param string|null $timezone + * @param array|string|null $dbConfig */ public function __construct( ModelManager $modelManager, @@ -69,7 +68,7 @@ public function __construct( $version, $versionText, $revision, - $timezone + $dbConfig ) { $this->modelManager = $modelManager; $this->environmentRepository = $environmentRepository; @@ -78,7 +77,13 @@ public function __construct( $this->version = $version; $this->versionText = $versionText; $this->revision = $revision; - $this->timezone = $timezone === '' ? null : $timezone; + $timezone = $dbConfig; + + if (\is_array($dbConfig)) { + $timezone = isset($dbConfig[self::TIMEZONE_KEY]) ? $dbConfig[self::TIMEZONE_KEY] : null; + } + + $this->timezone = \is_string($timezone) && $timezone !== '' ? $timezone : null; } /** diff --git a/Tests/Unit/Service/EnvironmentServiceTest.php b/Tests/Unit/Service/EnvironmentServiceTest.php index d97277e..39faf1d 100644 --- a/Tests/Unit/Service/EnvironmentServiceTest.php +++ b/Tests/Unit/Service/EnvironmentServiceTest.php @@ -22,16 +22,16 @@ class EnvironmentServiceTest extends TestCase { /** - * @dataProvider getDifferentTimeZones + * @dataProvider getDifferentDatabaseConfigs * - * @param string|null $timezone - * @param string|null $expectedTimezone + * @param array $dbConfig + * @param string|null $expectedTimezone * * @return void */ - public function testGetEnvironmentInformationReturnsDatabaseTimezone($timezone, $expectedTimezone) + public function testGetEnvironmentInformationReturnsDatabaseTimezone($dbConfig, $expectedTimezone) { - $environmentService = $this->createEnvironmentService($timezone); + $environmentService = $this->createEnvironmentService($dbConfig); $environmentInformation = $environmentService->getEnvironmentInformation(); @@ -40,36 +40,40 @@ public function testGetEnvironmentInformationReturnsDatabaseTimezone($timezone, } /** - * @return array + * @return array, expectedTimezone: string|null}> */ - public function getDifferentTimeZones(): array + public function getDifferentDatabaseConfigs(): array { return [ + 'missing' => [ + 'dbConfig' => [], + 'expectedTimezone' => null, + ], 'null' => [ - 'timezone' => null, + 'dbConfig' => ['timezone' => null], 'expectedTimezone' => null, ], 'empty' => [ - 'timezone' => '', + 'dbConfig' => ['timezone' => ''], 'expectedTimezone' => null, ], 'Europe/Berlin' => [ - 'timezone' => 'Europe/Berlin', + 'dbConfig' => ['timezone' => 'Europe/Berlin'], 'expectedTimezone' => 'Europe/Berlin', ], 'Europe/London' => [ - 'timezone' => 'Europe/London', + 'dbConfig' => ['timezone' => 'Europe/London'], 'expectedTimezone' => 'Europe/London', ], ]; } /** - * @param string|null $timezone + * @param array $dbConfig * * @return EnvironmentService */ - private function createEnvironmentService($timezone) + private function createEnvironmentService($dbConfig) { return new EnvironmentService( $this->createModelManager(), @@ -79,7 +83,7 @@ private function createEnvironmentService($timezone) '5.7.20', 'Shopware 5.7.20', 'test-revision', - $timezone + $dbConfig ); } From 5cae73a834548c12a37eb925a995318722534baf Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 8 May 2026 08:19:59 +0200 Subject: [PATCH 10/21] Fix tests --- Service/EnvironmentService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Service/EnvironmentService.php b/Service/EnvironmentService.php index 43e4dfd..e386872 100644 --- a/Service/EnvironmentService.php +++ b/Service/EnvironmentService.php @@ -77,8 +77,8 @@ public function __construct( $this->version = $version; $this->versionText = $versionText; $this->revision = $revision; - $timezone = $dbConfig; + $timezone = null; if (\is_array($dbConfig)) { $timezone = isset($dbConfig[self::TIMEZONE_KEY]) ? $dbConfig[self::TIMEZONE_KEY] : null; } From 94f55da53fdc657ab0397930b04080445e9e5ef8 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 8 May 2026 08:22:10 +0200 Subject: [PATCH 11/21] Fix tests --- Tests/Unit/Service/EnvironmentServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Unit/Service/EnvironmentServiceTest.php b/Tests/Unit/Service/EnvironmentServiceTest.php index 39faf1d..dd85e76 100644 --- a/Tests/Unit/Service/EnvironmentServiceTest.php +++ b/Tests/Unit/Service/EnvironmentServiceTest.php @@ -42,7 +42,7 @@ public function testGetEnvironmentInformationReturnsDatabaseTimezone($dbConfig, /** * @return array, expectedTimezone: string|null}> */ - public function getDifferentDatabaseConfigs(): array + public function getDifferentDatabaseConfigs() { return [ 'missing' => [ From 4c60af57f7593a47055b26feebda9504793a6833 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Fri, 8 May 2026 08:25:54 +0200 Subject: [PATCH 12/21] Fix tests --- Service/EnvironmentService.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Service/EnvironmentService.php b/Service/EnvironmentService.php index e386872..14da13a 100644 --- a/Service/EnvironmentService.php +++ b/Service/EnvironmentService.php @@ -15,7 +15,7 @@ class EnvironmentService extends AbstractApiService { - public const TIMEZONE_KEY = 'timezone'; + const TIMEZONE_KEY = 'timezone'; /** * @var ModelManager @@ -58,6 +58,9 @@ class EnvironmentService extends AbstractApiService private $timezone; /** + * @param string $version + * @param string $versionText + * @param string $revision * @param array|string|null $dbConfig */ public function __construct( From 9e06e18b06f4ba9deb135b86b383061f88d638b8 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 12 May 2026 08:23:33 +0200 Subject: [PATCH 13/21] Fix threads --- Controllers/Api/SwagMigrationTimezone.php | 24 ++ Service/EnvironmentService.php | 23 +- .../Controllers/SwagMigrationTimezoneTest.php | 47 ++++ Tests/Unit/Service/EnvironmentServiceTest.php | 220 ------------------ 4 files changed, 75 insertions(+), 239 deletions(-) create mode 100644 Controllers/Api/SwagMigrationTimezone.php create mode 100644 Tests/Functional/Controllers/SwagMigrationTimezoneTest.php delete mode 100644 Tests/Unit/Service/EnvironmentServiceTest.php diff --git a/Controllers/Api/SwagMigrationTimezone.php b/Controllers/Api/SwagMigrationTimezone.php new file mode 100644 index 0000000..c38bc42 --- /dev/null +++ b/Controllers/Api/SwagMigrationTimezone.php @@ -0,0 +1,24 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use SwagMigrationConnector\Controllers\SwagMigrationApiControllerBase; +use SwagMigrationConnector\Service\ControllerReturnStruct; + +class Shopware_Controllers_Api_SwagMigrationTimezone extends SwagMigrationApiControllerBase +{ + + public function indexAction() + { + $dbConfig = $this->container->getParameter('shopware.db'); + + $response = new ControllerReturnStruct([ + ['timezone' => $dbConfig['timezone'] ?? null] + ]); + + $this->view->assign($response->jsonSerialize()); + } +} diff --git a/Service/EnvironmentService.php b/Service/EnvironmentService.php index 14da13a..71108f8 100644 --- a/Service/EnvironmentService.php +++ b/Service/EnvironmentService.php @@ -53,15 +53,9 @@ class EnvironmentService extends AbstractApiService private $revision; /** - * @var string|null - */ - private $timezone; - - /** - * @param string $version - * @param string $versionText - * @param string $revision - * @param array|string|null $dbConfig + * @param string $version + * @param string $versionText + * @param string $revision */ public function __construct( ModelManager $modelManager, @@ -70,8 +64,7 @@ public function __construct( PluginInformationService $pluginInformationService, $version, $versionText, - $revision, - $dbConfig + $revision ) { $this->modelManager = $modelManager; $this->environmentRepository = $environmentRepository; @@ -80,13 +73,6 @@ public function __construct( $this->version = $version; $this->versionText = $versionText; $this->revision = $revision; - - $timezone = null; - if (\is_array($dbConfig)) { - $timezone = isset($dbConfig[self::TIMEZONE_KEY]) ? $dbConfig[self::TIMEZONE_KEY] : null; - } - - $this->timezone = \is_string($timezone) && $timezone !== '' ? $timezone : null; } /** @@ -116,7 +102,6 @@ public function getEnvironmentInformation() 'additionalData' => $this->getAdditionalData(), 'updateAvailable' => $this->pluginInformationService->isUpdateRequired($locale), 'config' => $config, - 'timezone' => $this->timezone, ]; return $resultSet; diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php new file mode 100644 index 0000000..1b79fa2 --- /dev/null +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -0,0 +1,47 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationConnector\Tests\Functional\Controllers; + +use Shopware_Controllers_Api_SwagMigrationTimezone as SwagMigrationTimezone; +use SwagMigrationConnector\Tests\Functional\ContainerTrait; +use SwagMigrationConnector\Tests\Functional\Controllers\ControllerFactory\Arguments; +use SwagMigrationConnector\Tests\Functional\Controllers\ControllerFactory\ControllerFactory; + +require __DIR__ . '/../../../Controllers/Api/SwagMigrationTimezone.php'; + +class SwagMigrationTimezoneTest extends \Enlight_Components_Test_Controller_TestCase +{ + use ContainerTrait; + + /** + * @return void + */ + public function testIndexActionReturnsConfiguredDatabaseTimezone() + { + $container = $this->getContainer(); + $dbConfig = $container->getParameter('shopware.db'); + $timezone = $dbConfig['timezone'] === '' ? null : $dbConfig['timezone']; + + $controller = ControllerFactory::createController( + SwagMigrationTimezone::class, + new Arguments($container) + ); + + $controller->indexAction(); + + static::assertSame([ + 'data' => [ + [ + 'timezone' => $timezone, + ], + ], + 'isLastRequest' => false, + 'success' => true, + ], $controller->View()->getAssign()); + } +} diff --git a/Tests/Unit/Service/EnvironmentServiceTest.php b/Tests/Unit/Service/EnvironmentServiceTest.php deleted file mode 100644 index dd85e76..0000000 --- a/Tests/Unit/Service/EnvironmentServiceTest.php +++ /dev/null @@ -1,220 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationConnector\Tests\Unit\Service; - -use Doctrine\ORM\EntityRepository; -use PHPUnit\Framework\TestCase; -use Shopware\Components\Model\ModelManager; -use Shopware\Models\Shop\Currency; -use Shopware\Models\Shop\Locale; -use Shopware\Models\Shop\Repository as ShopRepository; -use Shopware\Models\Shop\Shop; -use SwagMigrationConnector\Repository\ConfigRepository; -use SwagMigrationConnector\Repository\EnvironmentRepository; -use SwagMigrationConnector\Service\EnvironmentService; -use SwagMigrationConnector\Service\PluginInformationService; - -class EnvironmentServiceTest extends TestCase -{ - /** - * @dataProvider getDifferentDatabaseConfigs - * - * @param array $dbConfig - * @param string|null $expectedTimezone - * - * @return void - */ - public function testGetEnvironmentInformationReturnsDatabaseTimezone($dbConfig, $expectedTimezone) - { - $environmentService = $this->createEnvironmentService($dbConfig); - - $environmentInformation = $environmentService->getEnvironmentInformation(); - - static::assertArrayHasKey('timezone', $environmentInformation); - static::assertSame($expectedTimezone, $environmentInformation['timezone']); - } - - /** - * @return array, expectedTimezone: string|null}> - */ - public function getDifferentDatabaseConfigs() - { - return [ - 'missing' => [ - 'dbConfig' => [], - 'expectedTimezone' => null, - ], - 'null' => [ - 'dbConfig' => ['timezone' => null], - 'expectedTimezone' => null, - ], - 'empty' => [ - 'dbConfig' => ['timezone' => ''], - 'expectedTimezone' => null, - ], - 'Europe/Berlin' => [ - 'dbConfig' => ['timezone' => 'Europe/Berlin'], - 'expectedTimezone' => 'Europe/Berlin', - ], - 'Europe/London' => [ - 'dbConfig' => ['timezone' => 'Europe/London'], - 'expectedTimezone' => 'Europe/London', - ], - ]; - } - - /** - * @param array $dbConfig - * - * @return EnvironmentService - */ - private function createEnvironmentService($dbConfig) - { - return new EnvironmentService( - $this->createModelManager(), - $this->createEnvironmentRepository(), - $this->createConfigRepository(), - $this->createPluginInformationService(), - '5.7.20', - 'Shopware 5.7.20', - 'test-revision', - $dbConfig - ); - } - - /** - * @return ModelManager - */ - private function createModelManager() - { - $modelManager = $this->getMockBuilder(ModelManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $modelManager->expects(static::exactly(2)) - ->method('getRepository') - ->willReturnMap([ - [Shop::class, $this->createShopRepository()], - [Currency::class, $this->createCurrencyRepository()], - ]); - - return $modelManager; - } - - /** - * @return ShopRepository - */ - private function createShopRepository() - { - $shopRepository = $this->getMockBuilder(ShopRepository::class) - ->disableOriginalConstructor() - ->setMethods(['getDefault']) - ->getMock(); - - $shopRepository->expects(static::once()) - ->method('getDefault') - ->willReturn($this->createDefaultShop()); - - return $shopRepository; - } - - /** - * @return EntityRepository - */ - private function createCurrencyRepository() - { - $currencyRepository = $this->getMockBuilder(EntityRepository::class) - ->disableOriginalConstructor() - ->setMethods(['findOneBy']) - ->getMock(); - - $currencyRepository->expects(static::once()) - ->method('findOneBy') - ->with(['default' => 1]) - ->willReturn($this->createDefaultCurrency()); - - return $currencyRepository; - } - - /** - * @return EnvironmentRepository - */ - private function createEnvironmentRepository() - { - $environmentRepository = $this->getMockBuilder(EnvironmentRepository::class) - ->disableOriginalConstructor() - ->setMethods(['getShops']) - ->getMock(); - - $environmentRepository->expects(static::once()) - ->method('getShops') - ->willReturn([]); - - return $environmentRepository; - } - - /** - * @return ConfigRepository - */ - private function createConfigRepository() - { - $configRepository = $this->getMockBuilder(ConfigRepository::class) - ->disableOriginalConstructor() - ->setMethods(['fetch']) - ->getMock(); - - $configRepository->expects(static::once()) - ->method('fetch') - ->willReturn([]); - - return $configRepository; - } - - /** - * @return PluginInformationService - */ - private function createPluginInformationService() - { - $pluginInformationService = $this->getMockBuilder(PluginInformationService::class) - ->disableOriginalConstructor() - ->setMethods(['isUpdateRequired']) - ->getMock(); - - $pluginInformationService->expects(static::once()) - ->method('isUpdateRequired') - ->with('en-GB') - ->willReturn(false); - - return $pluginInformationService; - } - - /** - * @return Shop - */ - private function createDefaultShop() - { - $locale = new Locale(); - $locale->setLocale('en_GB'); - - $shop = new Shop(); - $shop->setLocale($locale); - - return $shop; - } - - /** - * @return Currency - */ - private function createDefaultCurrency() - { - $currency = new Currency(); - $currency->setCurrency('EUR'); - - return $currency; - } -} From e545dab0a6d69b305433bb9686ce0b19bcde1e7c Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 12 May 2026 08:36:37 +0200 Subject: [PATCH 14/21] Fix tests --- Controllers/Api/SwagMigrationTimezone.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Controllers/Api/SwagMigrationTimezone.php b/Controllers/Api/SwagMigrationTimezone.php index c38bc42..70c091a 100644 --- a/Controllers/Api/SwagMigrationTimezone.php +++ b/Controllers/Api/SwagMigrationTimezone.php @@ -10,13 +10,15 @@ class Shopware_Controllers_Api_SwagMigrationTimezone extends SwagMigrationApiControllerBase { - + /** + * @return void + */ public function indexAction() { $dbConfig = $this->container->getParameter('shopware.db'); $response = new ControllerReturnStruct([ - ['timezone' => $dbConfig['timezone'] ?? null] + ['timezone' => $dbConfig['timezone'] ?? null], ]); $this->view->assign($response->jsonSerialize()); From 007b42dde854bf4c13fcb9ee141dfd229e7ccd21 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 12 May 2026 09:09:27 +0200 Subject: [PATCH 15/21] Fix tests --- Controllers/Api/SwagMigrationTimezone.php | 10 +++++++++- .../Controllers/SwagMigrationTimezoneTest.php | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Controllers/Api/SwagMigrationTimezone.php b/Controllers/Api/SwagMigrationTimezone.php index 70c091a..4fe2fb5 100644 --- a/Controllers/Api/SwagMigrationTimezone.php +++ b/Controllers/Api/SwagMigrationTimezone.php @@ -16,9 +16,17 @@ class Shopware_Controllers_Api_SwagMigrationTimezone extends SwagMigrationApiCon public function indexAction() { $dbConfig = $this->container->getParameter('shopware.db'); + \assert(\is_array($dbConfig)); + + $timezone = $dbConfig['timezone'] ?? null; + \assert($timezone === null || \is_string($timezone)); + + if ($timezone === '') { + $timezone = null; + } $response = new ControllerReturnStruct([ - ['timezone' => $dbConfig['timezone'] ?? null], + ['timezone' => $timezone], ]); $this->view->assign($response->jsonSerialize()); diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php index 1b79fa2..f244c23 100644 --- a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -25,7 +25,10 @@ public function testIndexActionReturnsConfiguredDatabaseTimezone() { $container = $this->getContainer(); $dbConfig = $container->getParameter('shopware.db'); - $timezone = $dbConfig['timezone'] === '' ? null : $dbConfig['timezone']; + static::assertIsArray($dbConfig); + + $configuredTimezone = $dbConfig['timezone'] ?? null; + $timezone = $configuredTimezone === '' ? null : $configuredTimezone; $controller = ControllerFactory::createController( SwagMigrationTimezone::class, From 2ed628e2163db3f989f43b6265cacb25a0f3415a Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 12 May 2026 09:14:51 +0200 Subject: [PATCH 16/21] Fix tests --- Controllers/Api/SwagMigrationTimezone.php | 4 +--- Tests/Functional/Controllers/SwagMigrationTimezoneTest.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Controllers/Api/SwagMigrationTimezone.php b/Controllers/Api/SwagMigrationTimezone.php index 4fe2fb5..02bf64f 100644 --- a/Controllers/Api/SwagMigrationTimezone.php +++ b/Controllers/Api/SwagMigrationTimezone.php @@ -18,9 +18,7 @@ public function indexAction() $dbConfig = $this->container->getParameter('shopware.db'); \assert(\is_array($dbConfig)); - $timezone = $dbConfig['timezone'] ?? null; - \assert($timezone === null || \is_string($timezone)); - + $timezone = $dbConfig['timezone']; if ($timezone === '') { $timezone = null; } diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php index f244c23..8b5f3b3 100644 --- a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -27,7 +27,7 @@ public function testIndexActionReturnsConfiguredDatabaseTimezone() $dbConfig = $container->getParameter('shopware.db'); static::assertIsArray($dbConfig); - $configuredTimezone = $dbConfig['timezone'] ?? null; + $configuredTimezone = $dbConfig['timezone']; $timezone = $configuredTimezone === '' ? null : $configuredTimezone; $controller = ControllerFactory::createController( From 9d7eecf8c03afe2511d459bdbed40278187dd5c1 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 12 May 2026 09:16:47 +0200 Subject: [PATCH 17/21] Fix tests --- Tests/Functional/Controllers/SwagMigrationTimezoneTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php index 8b5f3b3..117f7fa 100644 --- a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -25,7 +25,7 @@ public function testIndexActionReturnsConfiguredDatabaseTimezone() { $container = $this->getContainer(); $dbConfig = $container->getParameter('shopware.db'); - static::assertIsArray($dbConfig); + static::assertTrue(\is_array($dbConfig)); $configuredTimezone = $dbConfig['timezone']; $timezone = $configuredTimezone === '' ? null : $configuredTimezone; From 2d0c64afa8973ee6bf129b3b94a6f3305617ec1a Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 12 May 2026 09:19:16 +0200 Subject: [PATCH 18/21] remove unsused const --- Service/EnvironmentService.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Service/EnvironmentService.php b/Service/EnvironmentService.php index 71108f8..1c1d643 100644 --- a/Service/EnvironmentService.php +++ b/Service/EnvironmentService.php @@ -15,8 +15,6 @@ class EnvironmentService extends AbstractApiService { - const TIMEZONE_KEY = 'timezone'; - /** * @var ModelManager */ From 7b628bcb9a0b216b38d3d44d639a64424f8db1d1 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 19 May 2026 07:36:18 +0200 Subject: [PATCH 19/21] Fix threads --- Controllers/Api/SwagMigrationTimezone.php | 22 +++++++- .../Controllers/SwagMigrationTimezoneTest.php | 52 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/Controllers/Api/SwagMigrationTimezone.php b/Controllers/Api/SwagMigrationTimezone.php index 02bf64f..b71705d 100644 --- a/Controllers/Api/SwagMigrationTimezone.php +++ b/Controllers/Api/SwagMigrationTimezone.php @@ -16,7 +16,15 @@ class Shopware_Controllers_Api_SwagMigrationTimezone extends SwagMigrationApiCon public function indexAction() { $dbConfig = $this->container->getParameter('shopware.db'); - \assert(\is_array($dbConfig)); + if (!\is_array($dbConfig)) { + $this->assignEmptyResult(); + return; + } + + if (!isset($dbConfig['timezone'])) { + $this->assignEmptyResult(); + return; + } $timezone = $dbConfig['timezone']; if ($timezone === '') { @@ -29,4 +37,16 @@ public function indexAction() $this->view->assign($response->jsonSerialize()); } + + /** + * @return void + */ + private function assignEmptyResult() + { + $response = new ControllerReturnStruct([ + ['timezone' => null], + ]); + + $this->view->assign($response->jsonSerialize()); + } } diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php index 117f7fa..b267590 100644 --- a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -8,9 +8,11 @@ namespace SwagMigrationConnector\Tests\Functional\Controllers; use Shopware_Controllers_Api_SwagMigrationTimezone as SwagMigrationTimezone; +use Shopware\Components\DependencyInjection\Container; use SwagMigrationConnector\Tests\Functional\ContainerTrait; use SwagMigrationConnector\Tests\Functional\Controllers\ControllerFactory\Arguments; use SwagMigrationConnector\Tests\Functional\Controllers\ControllerFactory\ControllerFactory; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; require __DIR__ . '/../../../Controllers/Api/SwagMigrationTimezone.php'; @@ -37,6 +39,56 @@ public function testIndexActionReturnsConfiguredDatabaseTimezone() $controller->indexAction(); + $this->assertTimezoneResponse($timezone, $controller); + } + + /** + * @return void + */ + public function testIndexActionReturnsNullTimezoneWhenDatabaseConfigHasNoTimezone() + { + $controller = $this->createControllerWithDatabaseConfig([]); + $controller->indexAction(); + + $this->assertTimezoneResponse(null, $controller); + } + + /** + * @return void + */ + public function testIndexActionReturnsNullTimezoneWhenDatabaseConfigIsNotArray() + { + $controller = $this->createControllerWithDatabaseConfig('invalid'); + $controller->indexAction(); + + $this->assertTimezoneResponse(null, $controller); + } + + /** + * @param mixed $dbConfig + * + * @return SwagMigrationTimezone + */ + private function createControllerWithDatabaseConfig($dbConfig) + { + $container = new Container(new ParameterBag([ + 'shopware.db' => $dbConfig, + ])); + + return ControllerFactory::createController( + SwagMigrationTimezone::class, + new Arguments($container) + ); + } + + /** + * @param string|null $timezone + * @param SwagMigrationTimezone $controller + * + * @return void + */ + private function assertTimezoneResponse($timezone, $controller) + { static::assertSame([ 'data' => [ [ From c75608d97074efea3b6e0decb3f8a3f7a6ed3f2c Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 19 May 2026 08:18:21 +0200 Subject: [PATCH 20/21] Fix CS and PHPStan --- Controllers/Api/SwagMigrationTimezone.php | 14 +++++++++++++- .../Controllers/SwagMigrationTimezoneTest.php | 6 ++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Controllers/Api/SwagMigrationTimezone.php b/Controllers/Api/SwagMigrationTimezone.php index b71705d..238bb13 100644 --- a/Controllers/Api/SwagMigrationTimezone.php +++ b/Controllers/Api/SwagMigrationTimezone.php @@ -18,11 +18,13 @@ public function indexAction() $dbConfig = $this->container->getParameter('shopware.db'); if (!\is_array($dbConfig)) { $this->assignEmptyResult(); + return; } - if (!isset($dbConfig['timezone'])) { + if (!$this->hasTimezoneConfig($dbConfig)) { $this->assignEmptyResult(); + return; } @@ -38,6 +40,16 @@ public function indexAction() $this->view->assign($response->jsonSerialize()); } + /** + * @param array $dbConfig + * + * @return bool + */ + private function hasTimezoneConfig(array $dbConfig) + { + return isset($dbConfig['timezone']); + } + /** * @return void */ diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php index b267590..9e8230d 100644 --- a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -7,8 +7,8 @@ namespace SwagMigrationConnector\Tests\Functional\Controllers; -use Shopware_Controllers_Api_SwagMigrationTimezone as SwagMigrationTimezone; use Shopware\Components\DependencyInjection\Container; +use Shopware_Controllers_Api_SwagMigrationTimezone as SwagMigrationTimezone; use SwagMigrationConnector\Tests\Functional\ContainerTrait; use SwagMigrationConnector\Tests\Functional\Controllers\ControllerFactory\Arguments; use SwagMigrationConnector\Tests\Functional\Controllers\ControllerFactory\ControllerFactory; @@ -65,8 +65,6 @@ public function testIndexActionReturnsNullTimezoneWhenDatabaseConfigIsNotArray() } /** - * @param mixed $dbConfig - * * @return SwagMigrationTimezone */ private function createControllerWithDatabaseConfig($dbConfig) @@ -82,7 +80,7 @@ private function createControllerWithDatabaseConfig($dbConfig) } /** - * @param string|null $timezone + * @param string|null $timezone * @param SwagMigrationTimezone $controller * * @return void From 07e3775549fa1b2739fc2a2dbb03a6c0ca63c334 Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Tue, 19 May 2026 08:21:18 +0200 Subject: [PATCH 21/21] Fix PHPStan --- Tests/Functional/Controllers/SwagMigrationTimezoneTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php index 9e8230d..7311c40 100644 --- a/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php +++ b/Tests/Functional/Controllers/SwagMigrationTimezoneTest.php @@ -65,6 +65,8 @@ public function testIndexActionReturnsNullTimezoneWhenDatabaseConfigIsNotArray() } /** + * @param array|string $dbConfig + * * @return SwagMigrationTimezone */ private function createControllerWithDatabaseConfig($dbConfig)