Skip to content

Commit

Permalink
Merge pull request #8 from BitBagCommerce/feature/OP-370-add-sylius-1…
Browse files Browse the repository at this point in the history
….13-support

Upgrade plugin to Sylius 1.13 compatibility
  • Loading branch information
senghe authored Aug 13, 2024
2 parents 2fc5165 + de8f5d8 commit 6d8e90d
Show file tree
Hide file tree
Showing 32 changed files with 2,210 additions and 1,099 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,31 @@ on:

jobs:
tests:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

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

strategy:
fail-fast: false
matrix:
php: ["8.1", "8.2"]
symfony: ["^5.4", "^6.0"]
sylius: ["~1.12.0"]
node: ["14.x"]
php: ["8.0", "8.1", "8.2", "8.3"]
symfony: ["^5.4", "^6.4"]
sylius: ["~1.12.0", "~1.13.0"]
node: ["^18.0", "^20.0"]
mysql: ["8.0"]
exclude:
- sylius: "~1.13.0"
php: "8.0"
- symfony: "^6.4"
php: "8.0"

env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"

steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3

-
name: Setup PHP
Expand All @@ -43,7 +48,7 @@ jobs:

-
name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: "${{ matrix.node }}"

Expand Down Expand Up @@ -81,7 +86,7 @@ jobs:

-
name: Cache Composer
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
Expand Down Expand Up @@ -133,7 +138,7 @@ jobs:
name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build)
(cd tests/Application && yarn encore dev)
-
name: Prepare test application cache
Expand All @@ -151,6 +156,10 @@ jobs:
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run ECS
run: vendor/bin/ecs check src

-
name: Run PHPStan
run: vendor/bin/phpstan analyse
Expand All @@ -165,13 +174,13 @@ jobs:

-
name: Upload Behat logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: Behat logs
path: etc/build/
if-no-files-found: ignore

-
name: Failed build Slack notification
uses: rtCamp/action-slack-notify@v2
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.0 || ^8.1",
"bitbag/shipping-export-plugin": "^3.0",
"msztorc/php-dpd-api": "^2.1",
"sylius/sylius": "~1.12.0",
"symfony/webpack-encore-bundle": "^1.17"
"sylius/sylius": "~1.12.0 || ~1.13.0",
"symfony/webpack-encore-bundle": "^1.17",
"ext-soap": "*"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down Expand Up @@ -47,7 +48,8 @@
"league/flysystem-bundle": "2.4.0"
},
"conflict": {
"sylius/resource-bundle": "1.9.1 || 1.9.0"
"sylius/resource-bundle": "1.9.1 || 1.9.0",
"behat/mink-selenium2-driver": ">=1.7.0"
},
"config": {
"sort-packages": true,
Expand Down
21 changes: 9 additions & 12 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<?php

use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');

$containerConfigurator->parameters()->set(Option::SKIP, [
VisibilityRequiredFixer::class => ['*Spec.php'],
]);
declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ECSConfig $config): void {
putenv('ALLOW_BITBAG_OS_HEADER=1');

$config->import('vendor/bitbag/coding-standard/ecs.php');
$config->paths(['src', 'tests']);
};
4 changes: 2 additions & 2 deletions features/exporting_shipping_data_to_api_dpd.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Feature: Managing shipping gateway
And it has "package_length" field set to "22"
And it has "cod_payment_method_code" field set to "stripe_checkout"
And it has "collect_on_delivery_form" field set to "BANK_TRANSFER"
And the store has a product "Chicken" priced at "$2" in "Web-US" channel
And the store has a product "Chicken" priced at "$2.00" in "Web-US" channel
And customer "[email protected]" has placed 5 orders on the "Web-US" channel in each buying 5 "Chicken" products
And the customer set the shipping address "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" to orders
And those orders were placed with "DPD Express" shipping method
And set product weight to "10"
And set product weight to "10.00"
And set units to the shipment

@ui
Expand Down
9 changes: 5 additions & 4 deletions src/Api/SoapClient.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
9 changes: 5 additions & 4 deletions src/Api/SoapClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
19 changes: 10 additions & 9 deletions src/Api/WebClient.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down Expand Up @@ -104,11 +105,11 @@ public function getServices(): array
];
}

if (method_exists($this->getOrder(), 'getDpdCud') && $this->getOrder()->getDpdCud() === true) {
if (method_exists($this->getOrder(), 'getDpdCud') && true === $this->getOrder()->getDpdCud()) {
$services['cud'] = '';
}

if (method_exists($this->getOrder(), 'getDpdGuarantee') && $this->getOrder()->getDpdGuarantee() !== null) {
if (method_exists($this->getOrder(), 'getDpdGuarantee') && null !== $this->getOrder()->getDpdGuarantee()) {
$services['guarantee'] = [
'type' => $this->getOrder()->getDpdGuarantee(),
];
Expand Down Expand Up @@ -193,11 +194,11 @@ private function resolveWeekend(\DateTime $date): \DateTime
{
$dayOfWeek = (int) $date->format('N');

if ($dayOfWeek === 6) {
if (6 === $dayOfWeek) {
return $date->modify('+2 days');
}

if ($dayOfWeek === 7) {
if (7 === $dayOfWeek) {
return $date->modify('+1 day');
}

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

$postCode = $shippingAddress->getPostcode();

return $postCode !== null ? str_replace('-', '', $postCode) : '';
return null !== $postCode ? str_replace('-', '', $postCode) : '';
}
}
9 changes: 5 additions & 4 deletions src/Api/WebClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
9 changes: 5 additions & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
9 changes: 5 additions & 4 deletions src/DependencyInjection/DpdPlShippingExportExtension.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
9 changes: 5 additions & 4 deletions src/DpdPlShippingExportPlugin.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
23 changes: 12 additions & 11 deletions src/EventListener/ShippingExportEventListener.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down Expand Up @@ -42,7 +43,7 @@ public function __construct(
RequestStack $requestStack,
FileSystem $fileSystem,
ObjectManager $shippingExportManager,
string $shippingLabelsPath
string $shippingLabelsPath,
) {
$this->webClient = $webClient;
$this->requestStack = $requestStack;
Expand All @@ -60,7 +61,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
$shippingGateway = $shippingExport->getShippingGateway();
Assert::notNull($shippingGateway);

if ($shippingGateway->getCode() !== self::DPD_GATEWAY_CODE) {
if (self::DPD_GATEWAY_CODE !== $shippingGateway->getCode()) {
return;
}

Expand All @@ -79,7 +80,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
$shippingGateway->getConfigValue('id'),
$shippingGateway->getConfigValue('login'),
$shippingGateway->getConfigValue('password'),
$shippingGateway->getConfigValue('wsdl')
$shippingGateway->getConfigValue('wsdl'),
);

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

return;
Expand All @@ -105,7 +106,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo
public function saveShippingLabel(
ShippingExportInterface $shippingExport,
string $labelContent,
string $labelExtension
string $labelExtension,
): void {
$labelPath = $this->shippingLabelsPath
. '/' . $this->getFilename($shippingExport)
Expand Down Expand Up @@ -135,7 +136,7 @@ private function getFilename(ShippingExportInterface $shippingExport): string
[
$shipmentId,
preg_replace('~[^A-Za-z0-9]~', '', (string) $orderNumber),
]
],
);
}

Expand Down
9 changes: 5 additions & 4 deletions src/Form/Type/ShippingGatewayType.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* 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
*/
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

Expand Down
2 changes: 2 additions & 0 deletions tests/Application/.env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
APP_SECRET='ch4mb3r0f5ecr3ts'

KERNEL_CLASS='Tests\BitBag\DpdPlShippingExportPlugin\Application\Kernel'

DATABASE_URL=mysql://[email protected]/DPD_shipping_%kernel.environment%?serverVersion=8.0
Loading

0 comments on commit 6d8e90d

Please sign in to comment.