Skip to content

Commit

Permalink
Merge pull request #20 from JanPalen/feature/OP-371-upgrade-plugin-to…
Browse files Browse the repository at this point in the history
…-sylius-1.13-support

Upgrade plugin to Sylius 1.13 compatibility
  • Loading branch information
senghe authored Aug 13, 2024
2 parents 85b6825 + 12388c2 commit 34d43c5
Show file tree
Hide file tree
Showing 57 changed files with 397 additions and 637 deletions.
39 changes: 17 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,25 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.0]
node: [14.x]
symfony: [^4.4, ^5.2]
sylius: [~1.11.0]
mysql: [5.7, 8.0]
php: ["8.0", "8.1", "8.2", "8.3"]
node: ["^18.0", "^20.0"]
symfony: ["^5.4", "^6.4"]
sylius: ["~1.12.0", "~1.13.0"]
mysql: ["8.0"]

exclude:
- # Segmentation fault while clearing cache
php: 8.0
mysql: 5.7
-
sylius: ~1.9.0
php: 8.0
-
sylius: ~1.11.0
php: 7.4
- 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 @@ -51,7 +46,7 @@ jobs:

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

Expand Down Expand Up @@ -89,7 +84,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 All @@ -116,7 +111,7 @@ jobs:
-
name: Get Yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

-
name: Cache Yarn
Expand All @@ -138,8 +133,8 @@ jobs:
-
name: Prepare test application assets
run: |
(cd tests/Application && yarn encore dev)
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build)
-
name: Prepare test application cache
run: (cd tests/Application && bin/console cache:warmup -vvv)
Expand Down Expand Up @@ -170,14 +165,14 @@ 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
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ imports:

- { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/config.yml" }
```
Finish the installation by updating the database schema:
```bash
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
```

## Customization

Expand Down
45 changes: 20 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@
],
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"bitbag/shipping-export-plugin": "^3.0",
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0",
"ext-soap": "*"
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3",
"bitbag/shipping-export-plugin": "^3.1.0",
"sylius/sylius": "~1.12.0 || ~1.13.0",
"symfony/webpack-encore-bundle": "^1.17",
"ext-soap": "*"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"bitbag/coding-standard": "^1.0",
"behat/behat": "^3.7.0",
"behat/mink-selenium2-driver": "~1.6.0",
"bitbag/coding-standard": "^3.0.0",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink-browserkit-driver": "^1.4",
"friends-of-behat/mink-debug-extension": "^2.0.0",
"friends-of-behat/mink-extension": "^2.4",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/service-container-extension": "^1.0",
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.85",
"phpstan/phpstan-doctrine": "0.12.33",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sensiolabs/security-checker": "^6.0",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
"symfony/intl": "^4.4 || ^5.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"vimeo/psalm": "4.7.1"
"symfony/browser-kit": "^5.4 || 6.4",
"symfony/debug-bundle": "^5.4 || ^6.4",
"symfony/dotenv": "^5.4 || ^6.4",
"symfony/intl": "^5.4 || ^6.4",
"symfony/web-profiler-bundle": "^5.4 || ^6.4",
"vimeo/psalm": "^4.7 || ^5.0"
},
"config": {
"sort-packages": true,
Expand All @@ -54,12 +54,7 @@
}
},
"conflict": {
"doctrine/dbal": "^3.0",
"symfony/symfony": "4.1.8",
"symfony/browser-kit": "4.1.8",
"symfony/dom-crawler": "4.1.8",
"symfony/routing": "4.1.8",
"symfony/doctrine-bridge": "4.4.16"
"behat/mink-selenium2-driver": ">=1.7.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 5 additions & 9 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');
return static function (ECSConfig $config): void {
putenv('ALLOW_BITBAG_OS_HEADER=1');

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);
$config->import('vendor/bitbag/coding-standard/ecs.php');
$config->paths(['src', 'tests']);
};
2 changes: 1 addition & 1 deletion features/exporting_shipping_data_to_api_dhl24.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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 "DHL Express" shipping method
Expand Down
34 changes: 19 additions & 15 deletions src/Api/ShippingLabelFetcher.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
<?php

/*
* 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);

namespace BitBag\SyliusDhl24PlShippingExportPlugin\Api;

use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;

class ShippingLabelFetcher implements ShippingLabelFetcherInterface
{
/** @var WebClientInterface */
private $webClient;
private WebClientInterface $webClient;

/** @var SoapClientInterface */
private $soapClient;
private SoapClientInterface $soapClient;

/** @var string */
private $response;
private object $response;

private FlashBagInterface $flashBag;
private RequestStack $requestStack;

public function __construct(
FlashBagInterface $flashBag,
RequestStack $requestStack,
WebClientInterface $webClient,
SoapClientInterface $soapClient
SoapClientInterface $soapClient,
) {
$this->flashBag = $flashBag;
$this->requestStack = $requestStack;
$this->webClient = $webClient;
$this->soapClient = $soapClient;
}
Expand All @@ -38,13 +42,13 @@ public function createShipment($shippingGateway, $shipment): void

$this->response = $this->soapClient->createShipment($requestData, $shippingGateway->getConfigValue('wsdl'));
} catch (\SoapFault $exception) {
$this->flashBag->add(
$this->requestStack->getSession()->getBag('flashes')->add(
'error',
sprintf(
'DHL24 Web Service for #%s order: %s',
$shipment->getOrder()->getNumber(),
$exception->getMessage()
)
$exception->getMessage(),
),
);

return;
Expand All @@ -57,7 +61,7 @@ public function getLabelContent(): ?string
return '';
}

$this->flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification
$this->requestStack->getSession()->getBag('flashes')->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification

return base64_decode($this->response->createShipmentResult->label->labelContent);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Api/ShippingLabelFetcherInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* 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);

namespace BitBag\SyliusDhl24PlShippingExportPlugin\Api;
Expand Down
7 changes: 3 additions & 4 deletions src/Api/SoapClient.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* This file was created by the developers from BitBag.
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on [email protected].
* 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
7 changes: 7 additions & 0 deletions src/Api/SoapClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* 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);

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

/*
* This file was created by the developers from BitBag.
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on [email protected].
* 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 @@ -166,7 +165,7 @@ private function resolveHouseNumber(AddressInterface $address): string
'Street "%s" is invalid. The street format must be something like %s, where %d is the house number.',
$street,
'"Opolska 45"',
45
45,
));

return end($streetParts);
Expand Down
7 changes: 3 additions & 4 deletions src/Api/WebClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* This file was created by the developers from BitBag.
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on [email protected].
* 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
7 changes: 3 additions & 4 deletions src/BitBagDhl24PlShippingExportPlugin.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* This file was created by the developers from BitBag.
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on [email protected].
* 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/*
* This file was created by the developers from BitBag.
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on [email protected].
* 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
Loading

0 comments on commit 34d43c5

Please sign in to comment.