Skip to content

Commit

Permalink
Merge pull request #6 from tomkalon/OP-372
Browse files Browse the repository at this point in the history
Op 372 / Added Sylius 1.12 & 1.13 support
  • Loading branch information
senghe authored Sep 16, 2024
2 parents 90f4871 + 3a3ccb2 commit 620dc04
Show file tree
Hide file tree
Showing 85 changed files with 708 additions and 997 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0"]
symfony: ["^4.4", "^5.2"]
sylius: ["~1.11.0"]
node: [ "10.x" ]
mysql: ["8.0"]

php: ["8.0", "8.1", "8.2"]
symfony: ["^5.4", "^6.0"]
sylius: ["~1.12.0", "~1.13.0"]
node: [ "14.x" ]
mysql: ["5.7", "8.0"]
exclude:
- sylius: ~1.10.0
symfony: 4.4

- sylius: ~1.11.0
php: 7.4
- sylius: "~1.13.0"
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 @@ -46,7 +43,7 @@ jobs:

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

Expand Down Expand Up @@ -126,7 +123,7 @@ jobs:
name: Install JS dependencies
run: |
(cd tests/Application && yarn install)
(cd tests/Application && yarn build)
(cd tests/Application && yarn encore dev)
-
name: Prepare test application database
Expand Down Expand Up @@ -176,7 +173,7 @@ jobs:
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
57 changes: 44 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ The SyliusPocztaPolskaShippingExportPlugin allows integrating Sylius with Poczta
---

```bash
$ composer require bitbag/poczta-polska-shipping-export-plugin

composer require bitbag/poczta-polska-shipping-export-plugin
```

Add plugin dependencies to your config/bundles.php file:
Expand All @@ -90,20 +89,52 @@ return [
];
```

Import required config in your `config/packages/bitbag_shipping_export_plugin.yaml` file (if it doesn't exist):

```yaml
# config/packages/bitbag_shipping_export_plugin.yaml

imports:
...

- { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/config.yml" }
```
Import routing in your `config/routes/bitbag_shipping_export_plugin.yaml` file (if it doesn't exist):

```yaml
# config/routes/bitbag_shipping_export_plugin.yaml
...
bitbag_shipping_export_plugin:
resource: "@BitBagSyliusShippingExportPlugin/Resources/config/routing.yml"
prefix: /admin
```


Finish the installation by updating the database schema:
```
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
bin/console cache:clear
```

## Testing
Recommended Node version for testing = 14.*

```bash
$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ bin/console doctrine:database:create --env=test
$ bin/console doctrine:schema:create --env=test
$ bin/console sylius:fixtures:load --env=test
$ APP_ENV=test symfony server:start --dir=public/
$ cd ../..
$ vendor/bin/behat
$ vendor/bin/phpspec run
composer install
cd tests/Application
yarn install
yarn run encore dev
bin/console doctrine:database:create --env=test
bin/console doctrine:schema:create --env=test
bin/console sylius:fixtures:load --env=test
APP_ENV=test symfony server:start --dir=public/
cd ../..
vendor/bin/behat
vendor/bin/phpspec run
```

# Functionalities
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/config/suites.yml
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml

default:
extensions:
Expand Down
142 changes: 69 additions & 73 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,72 @@
{
"name": "bitbag/poczta-polska-shipping-export-plugin",
"type": "sylius-plugin",
"description": "Poczta polska shipping export plugin for Sylius based applications.",
"keywords": [
"sylius",
"sylius-plugin"
],
"license": "MIT",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/damonsson/ElektronicznyNadawca"
}
],
"require": {
"php": "^7.4 || ^8.0",
"bitbag/shipping-export-plugin": "^3.0",
"printu/elektroniczny-nadawca": "dev-master",
"sylius/sylius": "~1.10.0 || ~1.11.0",
"ext-soap": "*"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"bitbag/coding-standard": "^1.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/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.99",
"phpstan/phpstan-doctrine": "0.12.33",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"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"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true,
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
"symfony/flex": true
}
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "src/",
"Tests\\BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "tests/"
}
},
"autoload-dev": {
"classmap": [
"tests/Application/Kernel.php"
]
"name": "bitbag/poczta-polska-shipping-export-plugin",
"type": "sylius-plugin",
"description": "Poczta polska shipping export plugin for Sylius based applications.",
"keywords": [
"sylius",
"sylius-plugin"
],
"license": "MIT",
"require": {
"php": "^8.0",
"ext-soap": "*",
"bitbag/shipping-export-plugin": "^3.0",
"printu/elektroniczny-nadawca": "^1.0.64",
"sylius/sylius": "~1.12.0 || ~1.13.0"
},
"require-dev": {
"behat/behat": "^3.7",
"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/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8.1",
"phpstan/phpstan-doctrine": "1.3.69",
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.17"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true,
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
"symfony/flex": true
}
},
"conflict": {
"doctrine/persistence": "<3.0"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "src/",
"Tests\\BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "tests/"
}
},
"autoload-dev": {
"classmap": [
"tests/Application/Kernel.php"
]
}
}

15 changes: 6 additions & 9 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

declare(strict_types=1);

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 {

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);
putenv('ALLOW_BITBAG_OS_HEADER=1');

$config->import('vendor/bitbag/coding-standard/ecs.php');
$config->paths(['src', 'tests']);
};
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 "PocztaPolska Express" shipping method
Expand Down
14 changes: 12 additions & 2 deletions spec/EventListener/ShippingExportEventListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\ShipmentInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

final class ShippingExportEventListenerSpec extends ObjectBehavior
{
Expand All @@ -39,7 +41,7 @@ function let(
Filesystem $filesystem,
ShippingExportRepository $shippingExportRepository,
WebClientInterface $webClient,
FlashBagInterface $flashBag,
RequestStack $requestStack,
FileNameGeneratorInterface $fileNameGenerator
): void {
$shippingLabelsPath = 'labels';
Expand All @@ -48,7 +50,7 @@ function let(
$shippingExportRepository,
$shippingLabelsPath,
$webClient,
$flashBag,
$requestStack,
$fileNameGenerator
);
}
Expand All @@ -66,6 +68,8 @@ function it_exports_shipment_successfully(
ShippingExportInterface $shippingExport,
OrderInterface $order,
FileNameGeneratorInterface $fileNameGenerator,
RequestStack $requestStack,
SessionInterface $session,
FlashBagInterface $flashBag,
getAddresLabelByGuidResponse $guidResponse
): void {
Expand All @@ -89,6 +93,8 @@ function it_exports_shipment_successfully(
self::ORDER_NUMBER
)
)->shouldBeCalled();
$requestStack->getSession()->willReturn($session);
$session->getBag('flashes')->willReturn($flashBag);
$flashBag->add(
'success',
'bitbag.ui.shipment_data_has_been_exported'
Expand Down Expand Up @@ -122,6 +128,8 @@ function it_should_handle_exception_when_webclient_fails(
WebClientInterface $webClient,
ShippingExportInterface $shippingExport,
OrderInterface $order,
RequestStack $requestStack,
SessionInterface $session,
FlashBagInterface $flashBag
): void {
$event->getSubject()->willReturn($shippingExport);
Expand All @@ -137,6 +145,8 @@ function it_should_handle_exception_when_webclient_fails(
$webClient->setShippingGateway($shippingGateway)->shouldBeCalled();
$webClient->setShipment($shipment)->shouldBeCalled();

$requestStack->getSession()->willReturn($session);
$session->getBag('flashes')->willReturn($flashBag);
$flashBag->add(
'error',
sprintf(
Expand Down
Loading

0 comments on commit 620dc04

Please sign in to comment.