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.13 #22

Merged
merged 3 commits into from
Jul 29, 2024
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
11 changes: 0 additions & 11 deletions .github/actions/roave-bc-check/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions .github/actions/roave-bc-check/action.yml

This file was deleted.

47 changes: 31 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
symfony: ["5.4.*", "^6.0"]
sylius: ["^1.12"]
php: [ "8.1", "8.2", "8.3" ]
symfony: [ "5.4.*", "^6.4" ]
sylius: ["1.13.3"]
node: ["18.x"]
mysql: ["5.7", "8.0"]
mysql: ["8.0"]

env:
APP_ENV: test
Expand All @@ -46,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 @@ -77,14 +77,18 @@ jobs:
name: Run webserver
run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)

-
name: Validate composer.json
run: composer validate --ansi --strict

-
name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

-
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 @@ -121,7 +125,7 @@ jobs:

-
name: Cache Yarn
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
Expand Down Expand Up @@ -152,10 +156,6 @@ jobs:
name: Load fixtures in test application
run: (cd tests/Application && bin/console sylius:fixtures:load -n)

-
name: Validate composer.json
run: composer validate --ansi --strict

-
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)
Expand Down Expand Up @@ -192,9 +192,24 @@ jobs:
roave_bc_check:
name: Roave BC Check
runs-on: ubuntu-latest
env:
PHP_VERSION: 8.2
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Roave BC Check
uses: ./.github/actions/roave-bc-check
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.PHP_VERSION }}"
extensions: intl
tools: flex,symfony
coverage: none

- name: Install roave/backward-compatibility-check.
run: composer require --dev roave/backward-compatibility-check --no-plugins

- name: Run roave/backward-compatibility-check.
run: vendor/bin/roave-backward-compatibility-check --format=github-actions
45 changes: 26 additions & 19 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ imports:
- tests/Behat/Resources/suites.yml

default:
formatters:
pretty:
verbose: true
paths: false
snippets: false

extensions:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
Robertfausk\Behat\PantherExtension: ~

FriendsOfBehat\MinkDebugExtension:
directory: etc/build
Expand All @@ -15,32 +22,30 @@ default:
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
base_url: "https://127.0.0.1:8080/"
default_session: symfony
javascript_session: chrome_headless
javascript_session: chromedriver
sessions:
symfony:
symfony: ~
chrome_headless:
chromedriver:
chrome:
api_url: http://127.0.0.1:9222
validate_certificate: false
chrome:
selenium2:
browser: chrome
capabilities:
browserName: chrome
browser: chrome
version: ""
marionette: null # https://github.com/Behat/MinkExtension/pull/311
chrome:
switches:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
extra_capabilities:
chrome_headless_second_session:
chrome:
api_url: http://127.0.0.1:9222
validate_certificate: false
panther:
panther:
manager_options:
connection_timeout_in_ms: 5000
request_timeout_in_ms: 120000
chromedriver_arguments:
- --log-path=etc/build/chromedriver.log
- --verbose
capabilities:
acceptSslCerts: true
acceptInsecureCerts: true
unexpectedAlertBehaviour: accept
firefox:
selenium2:
browser: firefox
show_auto: false

FriendsOfBehat\SymfonyExtension:
Expand All @@ -53,3 +58,5 @@ default:
FriendsOfBehat\SuiteSettingsExtension:
paths:
- "features"

SyliusLabs\SuiteTagsExtension: ~
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
],
"license": "MIT",
"require": {
"php": "^8.0",
"sylius/sylius": "^1.12",
"sylius/mailer-bundle": "^1.8 || ^2.0",
"php": "^8.1",
"sylius/sylius": "^1.13.3",
"symfony/webpack-encore-bundle": "^1.15"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"behat/mink-selenium2-driver": "^1.6",
"dbrekelmans/bdi": "^1.1",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -32,9 +32,11 @@
"phpstan/phpstan-doctrine": "1.3.16",
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6 || ^10.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"robertfausk/behat-panther-extension": "^1.1",
"sylius-labs/coding-standard": "^4.2",
"sylius-labs/suite-tags-extension": "^0.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
Expand Down
16 changes: 8 additions & 8 deletions features/managing_table_rates.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Feature: Managing table rates
@ui
Scenario: Updating a table rate
Given the store has a shipping table rate "East Coast Rates" for currency "USD"
And this shipping table rate has a rate "$5" for shipments up to 1000 kg
And this shipping table rate has a rate "$5.00" for shipments up to 1000 kg
And I want to modify the "East Coast Rates" table rate
When I change its name to "Edited Rates"
And I save my changes
Expand All @@ -52,8 +52,8 @@ Feature: Managing table rates
Scenario: Adding weight rates into a table rate
Given the store has a shipping table rate "East Coast Rates" for currency "USD"
And I want to modify the "East Coast Rates" table rate
When I add a new rate of "$5" for shipments up to 5 kg
And I add a new rate of "$10" for shipments up to 20 kg
When I add a new rate of "$5.00" for shipments up to 5 kg
And I add a new rate of "$10.00" for shipments up to 20 kg
And I save my changes
Then I should be notified that it has been successfully edited
And this shipping table rate should have 2 rates
Expand All @@ -63,21 +63,21 @@ Feature: Managing table rates
When I try to add a new shipping table
And I specify its code as "VALIDATE_ME"
And I specify its currency as "USD"
And I add a new rate of "$10" for shipments up to 20 kg
And I add a new rate of "$10.00" for shipments up to 20 kg
But I do not specify its name
And I try to add it
Then I should be notified that name is required
When I try to add a new shipping table
And I specify its name as "Validate Me"
And I specify its currency as "USD"
And I add a new rate of "$10" for shipments up to 20 kg
And I add a new rate of "$10.00" for shipments up to 20 kg
But I do not specify its code
And I try to add it
Then I should be notified that code is required
When I try to add a new shipping table
And I specify its code as "VALIDATE_ME"
And I specify its name as "Validate Me"
And I add a new rate of "$10" for shipments up to 20 kg
And I add a new rate of "$10.00" for shipments up to 20 kg
But I do not specify its currency
And I try to add it
Then I should be notified that currency is required
Expand All @@ -92,7 +92,7 @@ Feature: Managing table rates
@ui
Scenario: Trying to change table rate code (even if its field is disabled)
Given the store has a shipping table rate "East Coast Rates" for currency "USD"
And this shipping table rate has a rate "$5" for shipments up to 1000 kg
And this shipping table rate has a rate "$5.00" for shipments up to 1000 kg
And I want to modify the "East Coast Rates" table rate
Then the code field should be disabled
When I change its code to "ANOTHER_CODE"
Expand All @@ -103,7 +103,7 @@ Feature: Managing table rates
Scenario: Trying to change table rate currency (even if its field is disabled)
Given the store also operates on another channel named "Europe" in "EUR" currency
And the store has a shipping table rate "East Coast Rates" for currency "USD"
And this shipping table rate has a rate "$5" for shipments up to 1000 kg
And this shipping table rate has a rate "$5.00" for shipments up to 1000 kg
And I want to modify the "East Coast Rates" table rate
Then the currency field should be disabled
When I change its currency to "EUR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Feature: Seeing correct shipping fees for table rate based shipping methods
Given the store operates on a single channel in "United States"
And the store has a product "Bottle of water" which weights 1 kg
And the store has a shipping table rate "Weight-based" for currency "USD"
And it has a rate "$5" for shipments up to 5 kg
And it has a rate "$10" for shipments up to 20 kg
And it has a rate "$5.00" for shipments up to 5 kg
And it has a rate "$10.00" for shipments up to 20 kg
And the store has "Basic" shipping method using "Weight-based" table rate for "United States" channel
And I am a logged in customer

Expand Down
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
parameters:
level: max
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
paths:
- src
- tests/Behat

excludes_analyse:
excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'

Expand All @@ -15,4 +14,8 @@ parameters:
- 'tests/Application/src/**.php'

ignoreErrors:
-
identifier: missingType.generics
-
identifier: missingType.iterableValue
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
22 changes: 11 additions & 11 deletions spec/EventSubscriber/TableRateDeleteSubscriberSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,46 @@

class TableRateDeleteSubscriberSpec extends ObjectBehavior
{
function let(ShippingMethodRepositoryInterface $shippingMethodRepository)
public function let(ShippingMethodRepositoryInterface $shippingMethodRepository): void
{
$this->beConstructedWith($shippingMethodRepository);
}

function it_is_initializable()
public function it_is_initializable(): void
{
$this->shouldHaveType(TableRateDeleteSubscriber::class);
}

function it_should_implement_event_subscriber_interface()
public function it_should_implement_event_subscriber_interface(): void
{
$this->shouldImplement(EventSubscriberInterface::class);
}

function it_should_subscribe_to_table_rate_pre_delete_event()
public function it_should_subscribe_to_table_rate_pre_delete_event(): void
{
self::getSubscribedEvents()->shouldReturn(
['webgriffe.shipping_table_rate.pre_delete' => 'onTableRatePreDelete']
);
}

function it_should_stop_event_if_table_rate_is_already_in_use(
public function it_should_stop_event_if_table_rate_is_already_in_use(
ResourceControllerEvent $event,
ShippingMethodRepositoryInterface $shippingMethodRepository
) {
): void {
$tableRate = new ShippingTableRate();
$tableRate->setCode('TABLE_RATE');
$anotherTableRate = new ShippingTableRate();
$anotherTableRate->setCode('ANOTHER_RATE');
$shippingMethod1 = new ShippingMethod();
$shippingMethod1->setCode('METHOD1');
$shippingMethod1->setConfiguration(['WEB-US' => ['table_rate' => $tableRate]]);
$shippingMethod1->setConfiguration(['WEB-US' => ['table_rate' => 'TABLE_RATE']]);
$shippingMethod2 = new ShippingMethod();
$shippingMethod2->setCode('METHOD2');
$shippingMethod2->setConfiguration(['WEB-US' => ['table_rate' => $anotherTableRate]]);
$shippingMethod2->setConfiguration(['WEB-US' => ['table_rate' => 'ANOTHER_RATE']]);
$shippingMethod3 = new ShippingMethod();
$shippingMethod3->setCode('METHOD3');
$shippingMethod3->setConfiguration(
['WEB-US' => ['table_rate' => $anotherTableRate], 'WEB-EU' => ['table_rate' => $tableRate]]
['WEB-US' => ['table_rate' => 'ANOTHER_RATE'], 'WEB-EU' => ['table_rate' => 'TABLE_RATE']]
);
$shippingMethodRepository
->findBy(['calculator' => TableRateShippingCalculator::TYPE])
Expand All @@ -76,11 +76,11 @@ function it_should_stop_event_if_table_rate_is_already_in_use(
$this->onTableRatePreDelete($event);
}

function it_should_not_stop_event_if_table_rate_is_not_in_use(
public function it_should_not_stop_event_if_table_rate_is_not_in_use(
ShippingTableRate $shippingTableRate,
ResourceControllerEvent $event,
ShippingMethodRepositoryInterface $shippingMethodRepository
) {
): void {
$event->getSubject()->willReturn($shippingTableRate);
$shippingMethodRepository
->findBy(['calculator' => TableRateShippingCalculator::TYPE])
Expand Down
Loading
Loading