-
Notifications
You must be signed in to change notification settings - Fork 5
fix: consider time zone during migration of orders #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3061019
fix: consider time zone during migration of orders
DennisGarding 8329656
fix tests
DennisGarding 86c2bf8
fix cs
DennisGarding d1af9e7
fix test
DennisGarding df60eeb
remove codex file
DennisGarding cc2ad16
Read timezone from config
DennisGarding 49bf383
switch timezone information to environment reader
DennisGarding 07e8d35
Fix phpstan and remove unused test file
DennisGarding 6b5121f
Fix tests
DennisGarding 9ee86c4
Merge branch 'trunk' into 14186/time-zone-diff
DennisGarding 5cae73a
Fix tests
DennisGarding 94f55da
Fix tests
DennisGarding 4c60af5
Fix tests
DennisGarding 9e06e18
Fix threads
DennisGarding e545dab
Fix tests
DennisGarding 007b42d
Fix tests
DennisGarding 2ed628e
Fix tests
DennisGarding 9d7eecf
Fix tests
DennisGarding 2d0c64a
remove unsused const
DennisGarding 7b628bc
Fix threads
DennisGarding c75608d
Fix CS and PHPStan
DennisGarding 07e3775
Fix PHPStan
DennisGarding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ Thumbs.db | |
| vendor | ||
| .phpunit.result.cache | ||
| .php-cs-fixer.cache | ||
| .codex | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
| /** | ||
| * (c) shopware AG <info@shopware.com> | ||
| * 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 | ||
| { | ||
| /** | ||
| * @return void | ||
| */ | ||
| public function indexAction() | ||
| { | ||
| $dbConfig = $this->container->getParameter('shopware.db'); | ||
| if (!\is_array($dbConfig)) { | ||
| $this->assignEmptyResult(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| if (!$this->hasTimezoneConfig($dbConfig)) { | ||
| $this->assignEmptyResult(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| $timezone = $dbConfig['timezone']; | ||
| if ($timezone === '') { | ||
| $timezone = null; | ||
| } | ||
|
|
||
| $response = new ControllerReturnStruct([ | ||
| ['timezone' => $timezone], | ||
| ]); | ||
|
|
||
| $this->view->assign($response->jsonSerialize()); | ||
| } | ||
|
|
||
| /** | ||
| * @param array<string, mixed> $dbConfig | ||
| * | ||
| * @return bool | ||
| */ | ||
| private function hasTimezoneConfig(array $dbConfig) | ||
| { | ||
| return isset($dbConfig['timezone']); | ||
| } | ||
|
MalteJanz marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * @return void | ||
| */ | ||
| private function assignEmptyResult() | ||
| { | ||
| $response = new ControllerReturnStruct([ | ||
| ['timezone' => null], | ||
| ]); | ||
|
|
||
| $this->view->assign($response->jsonSerialize()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
Tests/Functional/Controllers/SwagMigrationTimezoneTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| <?php | ||
| /** | ||
| * (c) shopware AG <info@shopware.com> | ||
| * 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\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; | ||
| use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; | ||
|
|
||
| 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'); | ||
| static::assertTrue(\is_array($dbConfig)); | ||
|
|
||
| $configuredTimezone = $dbConfig['timezone']; | ||
| $timezone = $configuredTimezone === '' ? null : $configuredTimezone; | ||
|
|
||
| $controller = ControllerFactory::createController( | ||
| SwagMigrationTimezone::class, | ||
| new Arguments($container) | ||
| ); | ||
|
|
||
| $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 array<string, mixed>|string $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' => [ | ||
| [ | ||
| 'timezone' => $timezone, | ||
| ], | ||
| ], | ||
| 'isLastRequest' => false, | ||
| 'success' => true, | ||
| ], $controller->View()->getAssign()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.