Skip to content
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

Upgrade for Sylius 1.11 and drop support for Sylius 1.9, 1.10 and PHP 7.4 #16

Merged
merged 5 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ jobs:
tests:
runs-on: ubuntu-18.04

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

strategy:
fail-fast: false
matrix:
php: [8.0, 7.4]
node: [10.x]
mysql: [5.7, 8.0]

exclude:
- # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0
php: 7.3
mysql: 8.0
php: ["8.0"]
symfony: ["5.4.*"]
sylius: ["^1.11.2"]
node: ["14.x"]
mysql: ["8.0"]

env:
APP_ENV: test
Expand Down Expand Up @@ -94,6 +91,18 @@ jobs:
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-

-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"

-
name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

-
name: Install PHP dependencies
run: composer install --no-interaction
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
/behat.yml
/phpspec.yml
/phpunit.xml

# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project
/.php-version
/php.ini
49 changes: 30 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "webgriffe/sylius-table-rate-shipping-plugin",
"type": "sylius-plugin",
"keywords": ["sylius", "sylius-plugin"],
"description": "Provides table rate shipping calculator.",
"keywords": [
"sylius",
"sylius-plugin"
],
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"sylius/sylius": "~1.9.0 || ~1.10.0@beta"
"php": "^8.0",
"sylius/sylius": "^1.11"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand All @@ -24,19 +27,33 @@
"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": "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",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.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",
"symfony/debug-bundle": "^5.4",
"symfony/dotenv": "^5.4",
"symfony/intl": "^5.4",
"symfony/web-profiler-bundle": "^5.4",
"vimeo/psalm": "4.7.1",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/thanks": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
Expand All @@ -45,15 +62,9 @@
}
},
"autoload-dev": {
"classmap": ["tests/Application/Kernel.php"]
},
"extra": {
"branch-alias": {
"dev-master": "0.x-dev"
}
},
"config": {
"sort-packages": true
"classmap": [
"tests/Application/Kernel.php"
]
},
"scripts": {
"post-install-cmd": [
Expand Down
14 changes: 14 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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->parameters()->set(Option::SKIP, [
VisibilityRequiredFixer::class => ['*Spec.php'],
]);
};
6 changes: 1 addition & 5 deletions src/Calculator/TableRateShippingCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ final class TableRateShippingCalculator implements CalculatorInterface
{
public const TYPE = 'table_rate';

/** @var TableRateResolverInterface */
private $tableRateResolver;

public function __construct(TableRateResolverInterface $tableRateResolver)
public function __construct(private TableRateResolverInterface $tableRateResolver)
{
$this->tableRateResolver = $tableRateResolver;
}

public function calculate(BaseShipmentInterface $shipment, array $configuration): int
Expand Down
12 changes: 2 additions & 10 deletions src/Checker/TableRateShippingMethodEligibilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@

final class TableRateShippingMethodEligibilityChecker implements ShippingMethodEligibilityCheckerInterface
{
/** @var ShippingMethodEligibilityCheckerInterface */
private $eligibilityChecker;

/** @var TableRateResolverInterface */
private $tableRateResolver;

public function __construct(
ShippingMethodEligibilityCheckerInterface $eligibilityChecker,
TableRateResolverInterface $tableRateResolver
private ShippingMethodEligibilityCheckerInterface $eligibilityChecker,
private TableRateResolverInterface $tableRateResolver
) {
$this->eligibilityChecker = $eligibilityChecker;
$this->tableRateResolver = $tableRateResolver;
}

public function isEligible(
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('acme_sylius_example_plugin');
$treeBuilder = new TreeBuilder('webgriffe_sylius_table_rate_shipping_plugin');
LucaGallinari marked this conversation as resolved.
Show resolved Hide resolved

return $treeBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

final class WebgriffeSyliusTableRateShippingExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $config, ContainerBuilder $container): void
{
$this->processConfiguration($this->getConfiguration([], $container), $config);
Expand Down
9 changes: 1 addition & 8 deletions src/EventSubscriber/TableRateDeleteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@

class TableRateDeleteSubscriber implements EventSubscriberInterface
{
/** @var ShippingMethodRepositoryInterface */
private $shippingMethodRepository;

public function __construct(ShippingMethodRepositoryInterface $shippingMethodRepository)
public function __construct(private ShippingMethodRepositoryInterface $shippingMethodRepository)
{
$this->shippingMethodRepository = $shippingMethodRepository;
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return ['webgriffe.shipping_table_rate.pre_delete' => 'onTableRatePreDelete'];
Expand Down
3 changes: 0 additions & 3 deletions src/Form/EventSubscriber/AddCurrencySubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

class AddCurrencySubscriber implements EventSubscriberInterface
{
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [FormEvents::PRE_SET_DATA => 'preSetData'];
Expand Down
6 changes: 1 addition & 5 deletions src/Resolver/TableRateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@

final class TableRateResolver implements TableRateResolverInterface
{
/** @var RepositoryInterface */
private $tableRateRepository;

public function __construct(RepositoryInterface $tableRateRepository)
public function __construct(private RepositoryInterface $tableRateRepository)
{
$this->tableRateRepository = $tableRateRepository;
}

public function resolve(ShipmentInterface $shipment, array $calculatorConfig): ShippingTableRate
Expand Down
7 changes: 7 additions & 0 deletions tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ JWT_PASSPHRASE=acme_plugin_development
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###

###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
MESSENGER_TRANSPORT_DSN=doctrine://default
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
###< symfony/messenger ###
2 changes: 0 additions & 2 deletions tests/Application/.env.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
APP_SECRET='ch4mb3r0f5ecr3ts'

KERNEL_CLASS='Tests\Webgriffe\SyliusTableRateShippingPlugin\Application\Kernel'
APP_ENV=test
DATABASE_URL=sqlite:///%kernel.project_dir%/var/%kernel.environment%_db.sql
11 changes: 0 additions & 11 deletions tests/Application/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
module.exports = {
extends: 'airbnb-base',
rules: {
'function-paren-newline': ['error', 'consistent'],
'max-len': ['warn', 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
},
extends: 'airbnb-base',
env: {
node: true,
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment()) {
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
return MockerContainer::class;
}

Expand Down
6 changes: 4 additions & 2 deletions tests/Application/config/bundles.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true],
Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true],
Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true],
Webgriffe\SyliusTableRateShippingPlugin\WebgriffeSyliusTableRateShippingPlugin::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
Expand All @@ -53,6 +54,7 @@
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],

Webgriffe\SyliusTableRateShippingPlugin\WebgriffeSyliusTableRateShippingPlugin::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
];
3 changes: 3 additions & 0 deletions tests/Application/config/packages/_sylius.yaml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ parameters:
sylius_shop:
product_grid:
include_all_descendants: true

sylius_api:
enabled: true
10 changes: 10 additions & 0 deletions tests/Application/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
api_platform:
mapping:
paths:
- '%kernel.project_dir%/../../vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources'
- '%kernel.project_dir%/config/api_platform'
- '%kernel.project_dir%/src/Entity'
patch_formats:
json: ['application/merge-patch+json']
swagger:
versions: [3]
Empty file modified tests/Application/config/packages/dev/framework.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/dev/monolog.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/dev/routing.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/dev/swiftmailer.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/dev/web_profiler.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/doctrine.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/doctrine_migrations.yaml
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion tests/Application/config/packages/fos_rest.yaml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fos_rest:
empty_content: 204
format_listener:
rules:
- { path: '^/api/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
- { path: '^/api/v1/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
- { path: '^/', stop: true }
3 changes: 3 additions & 0 deletions tests/Application/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ framework:
csrf_protection: true
session:
handler_id: ~
serializer:
mapping:
paths: [ '%kernel.project_dir%/config/serialization' ]
Empty file modified tests/Application/config/packages/liip_imagine.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/prod/doctrine.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/prod/monolog.yaml
100755 → 100644
Empty file.
Empty file modified tests/Application/config/packages/routing.yaml
100755 → 100644
Empty file.
Loading