Skip to content

Commit 6d8e90d

Browse files
authored
Merge pull request #8 from BitBagCommerce/feature/OP-370-add-sylius-1.13-support
Upgrade plugin to Sylius 1.13 compatibility
2 parents 2fc5165 + de8f5d8 commit 6d8e90d

32 files changed

+2210
-1099
lines changed

.github/workflows/build.yml

+20-11
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,31 @@ on:
1111

1212
jobs:
1313
tests:
14-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-latest
1515

1616
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
1717

1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php: ["8.1", "8.2"]
22-
symfony: ["^5.4", "^6.0"]
23-
sylius: ["~1.12.0"]
24-
node: ["14.x"]
21+
php: ["8.0", "8.1", "8.2", "8.3"]
22+
symfony: ["^5.4", "^6.4"]
23+
sylius: ["~1.12.0", "~1.13.0"]
24+
node: ["^18.0", "^20.0"]
2525
mysql: ["8.0"]
26+
exclude:
27+
- sylius: "~1.13.0"
28+
php: "8.0"
29+
- symfony: "^6.4"
30+
php: "8.0"
2631

2732
env:
2833
APP_ENV: test
2934
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
3035

3136
steps:
3237
-
33-
uses: actions/checkout@v2
38+
uses: actions/checkout@v3
3439

3540
-
3641
name: Setup PHP
@@ -43,7 +48,7 @@ jobs:
4348

4449
-
4550
name: Setup Node
46-
uses: actions/setup-node@v1
51+
uses: actions/setup-node@v4
4752
with:
4853
node-version: "${{ matrix.node }}"
4954

@@ -81,7 +86,7 @@ jobs:
8186

8287
-
8388
name: Cache Composer
84-
uses: actions/cache@v2
89+
uses: actions/cache@v4
8590
with:
8691
path: ${{ steps.composer-cache.outputs.dir }}
8792
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
@@ -133,7 +138,7 @@ jobs:
133138
name: Prepare test application assets
134139
run: |
135140
(cd tests/Application && bin/console assets:install public -vvv)
136-
(cd tests/Application && yarn build)
141+
(cd tests/Application && yarn encore dev)
137142
138143
-
139144
name: Prepare test application cache
@@ -151,6 +156,10 @@ jobs:
151156
name: Validate database schema
152157
run: (cd tests/Application && bin/console doctrine:schema:validate)
153158

159+
-
160+
name: Run ECS
161+
run: vendor/bin/ecs check src
162+
154163
-
155164
name: Run PHPStan
156165
run: vendor/bin/phpstan analyse
@@ -165,13 +174,13 @@ jobs:
165174

166175
-
167176
name: Upload Behat logs
168-
uses: actions/upload-artifact@v2
177+
uses: actions/upload-artifact@v3
169178
if: failure()
170179
with:
171180
name: Behat logs
172181
path: etc/build/
173182
if-no-files-found: ignore
174-
183+
175184
-
176185
name: Failed build Slack notification
177186
uses: rtCamp/action-slack-notify@v2

composer.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.0",
13+
"php": "^8.0 || ^8.1",
1414
"bitbag/shipping-export-plugin": "^3.0",
1515
"msztorc/php-dpd-api": "^2.1",
16-
"sylius/sylius": "~1.12.0",
17-
"symfony/webpack-encore-bundle": "^1.17"
16+
"sylius/sylius": "~1.12.0 || ~1.13.0",
17+
"symfony/webpack-encore-bundle": "^1.17",
18+
"ext-soap": "*"
1819
},
1920
"require-dev": {
2021
"behat/behat": "^3.6.1",
@@ -47,7 +48,8 @@
4748
"league/flysystem-bundle": "2.4.0"
4849
},
4950
"conflict": {
50-
"sylius/resource-bundle": "1.9.1 || 1.9.0"
51+
"sylius/resource-bundle": "1.9.1 || 1.9.0",
52+
"behat/mink-selenium2-driver": ">=1.7.0"
5153
},
5254
"config": {
5355
"sort-packages": true,

ecs.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<?php
22

3-
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
4-
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
5-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6-
use Symplify\EasyCodingStandard\ValueObject\Option;
7-
8-
return static function (ContainerConfigurator $containerConfigurator): void {
9-
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
10-
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');
11-
12-
$containerConfigurator->parameters()->set(Option::SKIP, [
13-
VisibilityRequiredFixer::class => ['*Spec.php'],
14-
]);
3+
declare(strict_types=1);
4+
5+
use Symplify\EasyCodingStandard\Config\ECSConfig;
6+
7+
return static function (ECSConfig $config): void {
8+
putenv('ALLOW_BITBAG_OS_HEADER=1');
9+
10+
$config->import('vendor/bitbag/coding-standard/ecs.php');
11+
$config->paths(['src', 'tests']);
1512
};

features/exporting_shipping_data_to_api_dpd.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ Feature: Managing shipping gateway
3434
And it has "package_length" field set to "22"
3535
And it has "cod_payment_method_code" field set to "stripe_checkout"
3636
And it has "collect_on_delivery_form" field set to "BANK_TRANSFER"
37-
And the store has a product "Chicken" priced at "$2" in "Web-US" channel
37+
And the store has a product "Chicken" priced at "$2.00" in "Web-US" channel
3838
And customer "user@bitbag.pl" has placed 5 orders on the "Web-US" channel in each buying 5 "Chicken" products
3939
And the customer set the shipping address "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" to orders
4040
And those orders were placed with "DPD Express" shipping method
41-
And set product weight to "10"
41+
And set product weight to "10.00"
4242
And set units to the shipment
4343

4444
@ui

src/Api/SoapClient.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

src/Api/SoapClientInterface.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

src/Api/WebClient.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

@@ -104,11 +105,11 @@ public function getServices(): array
104105
];
105106
}
106107

107-
if (method_exists($this->getOrder(), 'getDpdCud') && $this->getOrder()->getDpdCud() === true) {
108+
if (method_exists($this->getOrder(), 'getDpdCud') && true === $this->getOrder()->getDpdCud()) {
108109
$services['cud'] = '';
109110
}
110111

111-
if (method_exists($this->getOrder(), 'getDpdGuarantee') && $this->getOrder()->getDpdGuarantee() !== null) {
112+
if (method_exists($this->getOrder(), 'getDpdGuarantee') && null !== $this->getOrder()->getDpdGuarantee()) {
112113
$services['guarantee'] = [
113114
'type' => $this->getOrder()->getDpdGuarantee(),
114115
];
@@ -193,11 +194,11 @@ private function resolveWeekend(\DateTime $date): \DateTime
193194
{
194195
$dayOfWeek = (int) $date->format('N');
195196

196-
if ($dayOfWeek === 6) {
197+
if (6 === $dayOfWeek) {
197198
return $date->modify('+2 days');
198199
}
199200

200-
if ($dayOfWeek === 7) {
201+
if (7 === $dayOfWeek) {
201202
return $date->modify('+1 day');
202203
}
203204

@@ -216,6 +217,6 @@ private function getPostCode(): string
216217

217218
$postCode = $shippingAddress->getPostcode();
218219

219-
return $postCode !== null ? str_replace('-', '', $postCode) : '';
220+
return null !== $postCode ? str_replace('-', '', $postCode) : '';
220221
}
221222
}

src/Api/WebClientInterface.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

src/DependencyInjection/Configuration.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

src/DependencyInjection/DpdPlShippingExportExtension.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

src/DpdPlShippingExportPlugin.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

src/EventListener/ShippingExportEventListener.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

@@ -42,7 +43,7 @@ public function __construct(
4243
RequestStack $requestStack,
4344
FileSystem $fileSystem,
4445
ObjectManager $shippingExportManager,
45-
string $shippingLabelsPath
46+
string $shippingLabelsPath,
4647
) {
4748
$this->webClient = $webClient;
4849
$this->requestStack = $requestStack;
@@ -60,7 +61,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
6061
$shippingGateway = $shippingExport->getShippingGateway();
6162
Assert::notNull($shippingGateway);
6263

63-
if ($shippingGateway->getCode() !== self::DPD_GATEWAY_CODE) {
64+
if (self::DPD_GATEWAY_CODE !== $shippingGateway->getCode()) {
6465
return;
6566
}
6667

@@ -79,7 +80,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
7980
$shippingGateway->getConfigValue('id'),
8081
$shippingGateway->getConfigValue('login'),
8182
$shippingGateway->getConfigValue('password'),
82-
$shippingGateway->getConfigValue('wsdl')
83+
$shippingGateway->getConfigValue('wsdl'),
8384
);
8485

8586
$dpd->setSender($this->webClient->getSender());
@@ -90,8 +91,8 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
9091
} catch (Exception $exception) {
9192
$session->getFlashBag()->add('error', sprintf(
9293
'DPD Web Service for #%s order: %s',
93-
$shipment->getOrder() !== null ? (string) $shipment->getOrder()->getNumber() : '',
94-
$exception->getMessage()
94+
null !== $shipment->getOrder() ? (string) $shipment->getOrder()->getNumber() : '',
95+
$exception->getMessage(),
9596
));
9697

9798
return;
@@ -105,7 +106,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
105106
public function saveShippingLabel(
106107
ShippingExportInterface $shippingExport,
107108
string $labelContent,
108-
string $labelExtension
109+
string $labelExtension,
109110
): void {
110111
$labelPath = $this->shippingLabelsPath
111112
. '/' . $this->getFilename($shippingExport)
@@ -135,7 +136,7 @@ private function getFilename(ShippingExportInterface $shippingExport): string
135136
[
136137
$shipmentId,
137138
preg_replace('~[^A-Za-z0-9]~', '', (string) $orderNumber),
138-
]
139+
],
139140
);
140141
}
141142

src/Form/Type/ShippingGatewayType.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

33
/*
4-
* This file was created by developers working at BitBag
5-
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6-
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7-
*/
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* You can find more information about us on https://bitbag.io and write us
7+
* an email on hello@bitbag.io.
8+
*/
89

910
declare(strict_types=1);
1011

tests/Application/.env.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
APP_SECRET='ch4mb3r0f5ecr3ts'
22

33
KERNEL_CLASS='Tests\BitBag\DpdPlShippingExportPlugin\Application\Kernel'
4+
5+
DATABASE_URL=mysql://root@127.0.0.1/DPD_shipping_%kernel.environment%?serverVersion=8.0

0 commit comments

Comments
 (0)