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 to Sylius 1.11 #124

Merged
merged 2 commits into from
Mar 28, 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
13 changes: 4 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0", "7.4"]
symfony: ["^4.4", "^5.2"]
sylius: ["~1.9.0", "~1.10.0@alpha"]
node: ["12.x"]
php: ["8.0"]
symfony: ["5.4.*"]
sylius: ["^1.11.2"]
node: ["14.x"]
mysql: ["8.0"]

exclude:
-
php: "8.0"
sylius: "~1.9.0"

env:
APP_ENV: test
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

## Requirements

* PHP `7.4` or `8.0`
* Sylius `1.9.x` or `1.10.x`
* PHP `^8.0`
* Sylius `^1.11`
* Akeneo PIM CE or EE `>= 3.2`.
The requirement for the version `3.2` is because the provided implementation of the product importer relies on the `family_variant` key in the Akeneo [GET Product model](https://api.akeneo.com/api-reference.html#get_product_models__code_) API response.

Expand Down
52 changes: 39 additions & 13 deletions bin/create_node_symlink.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
<?php
LucaGallinari marked this conversation as resolved.
Show resolved Hide resolved

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo '> This system is running Windows, we shall try to create a link and if it fails then a junction:' . PHP_EOL;
exec('mklink /D node_modules tests\\Application\\node_modules 2> NUL', $output, $returnCode);
if ($returnCode !== 0) {
echo '> Creation of Link failed; you can try with Admin privileges; trying to create a Junction:' . PHP_EOL;
exec('mklink /J node_modules tests\\Application\\node_modules 2> NUL', $output, $returnCode);
}
const NODE_MODULES_FOLDER_NAME = 'node_modules';
const PATH_TO_NODE_MODULES = 'tests' . DIRECTORY_SEPARATOR . 'Application' . DIRECTORY_SEPARATOR . 'node_modules';

if ($returnCode === 0) {
echo "> Successfully created a Link/Junction." . PHP_EOL;
/* cannot use `file_exists` or `stat` as gives false on symlinks if target path does not exist yet */
if (@lstat(NODE_MODULES_FOLDER_NAME))
{
if (is_link(NODE_MODULES_FOLDER_NAME) || is_dir(NODE_MODULES_FOLDER_NAME)) {
echo '> `' . NODE_MODULES_FOLDER_NAME . '` already exists as a link or folder, keeping existing as may be intentional.' . PHP_EOL;
exit(0);
} else {
echo "> Failed with return code: " . $returnCode;
echo '> Invalid symlink `' . NODE_MODULES_FOLDER_NAME . '` detected, recreating...' . PHP_EOL;
if (!@unlink(NODE_MODULES_FOLDER_NAME)) {
echo '> Could not delete file `' . NODE_MODULES_FOLDER_NAME . '`.' . PHP_EOL;
exit(1);
}
}
}

/* try to create the symlink using PHP internals... */
$success = @symlink(PATH_TO_NODE_MODULES, NODE_MODULES_FOLDER_NAME);

/* if case it has failed, but OS is Windows... */
if (!$success && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
/* ...then try a different approach which does not require elevated permissions and folder to exist */
echo '> This system is running Windows, creation of links requires elevated privileges,' . PHP_EOL;
echo '> and target path to exist. Fallback to NTFS Junction:' . PHP_EOL;
exec(sprintf('mklink /J %s %s 2> NUL', NODE_MODULES_FOLDER_NAME, PATH_TO_NODE_MODULES), $output, $returnCode);
$success = $returnCode === 0;
if (!$success) {
echo '> Failed o create the required symlink' . PHP_EOL;
exit(2);
}
} else {
echo '> This is a server not running Windows, we shall try to use a Symlink' . PHP_EOL;
passthru('ln -s tests/Application/node_modules node_modules');
}

$path = @readlink(NODE_MODULES_FOLDER_NAME);
/* check if link points to the intended directory */
if ($path && realpath($path) === realpath(PATH_TO_NODE_MODULES)) {
echo '> Successfully created the symlink.' . PHP_EOL;
exit(0);
}

echo '> Failed to create the symlink to `' . NODE_MODULES_FOLDER_NAME . '`.' . PHP_EOL;
exit(3);
21 changes: 11 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"description": "Plugin allowing to import products data from Akeneo PIM to your Sylius store.",
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"cocur/slugify": "^4.0",
"guzzlehttp/guzzle": "^6.5",
"sylius/sylius": "~1.9.0 || ~1.10.0@alpha",
"sylius/sylius": "^1.11.2",
"symfony/deprecation-contracts": "^2.2",
"symfony/lock": "^4.4|^5.0"
},
Expand All @@ -34,20 +34,21 @@
"mikey179/vfsstream": "^1.6",
"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",
"symfony/browser-kit": "^5.4",
"symfony/debug-bundle": "^5.4",
"symfony/dotenv": "^5.4",
"symfony/intl": "^5.4",
"symfony/web-profiler-bundle": "^5.4",
"theofidry/alice-data-fixtures": "^1.1",
"vimeo/psalm": "4.7.1"
"vimeo/psalm": "4.7.1",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"config": {
"sort-packages": true,
Expand All @@ -60,7 +61,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.10-dev"
"dev-master": "1.11-dev"
}
},
"autoload": {
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: 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
Empty file.
3 changes: 3 additions & 0 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::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
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
LucaGallinari marked this conversation as resolved.
Show resolved Hide resolved
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:
LucaGallinari marked this conversation as resolved.
Show resolved Hide resolved
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]
2 changes: 1 addition & 1 deletion tests/Application/config/packages/fos_rest.yaml
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:
LucaGallinari marked this conversation as resolved.
Show resolved Hide resolved
mapping:
paths: [ '%kernel.project_dir%/config/serialization' ]
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
parameters:
LucaGallinari marked this conversation as resolved.
Show resolved Hide resolved
sylius.security.admin_regex: "^/%sylius_admin.path_name%"
sylius.security.api_regex: "^/api"
sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++"
sylius.security.new_api_route: "/new-api"
sylius.security.new_api_regex: "^%sylius.security.new_api_route%"
sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin"
sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%"
sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop"
sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%"

security:
always_authenticate_before_granting: true
providers:
Expand All @@ -20,9 +9,6 @@ security:
id: sylius.shop_user_provider.email_or_name_based
sylius_api_shop_user_provider:
id: sylius.shop_user_provider.email_or_name_based
sylius_api_chain_provider:
chain:
providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider]

encoders:
Sylius\Component\User\Model\UserInterface: argon2i
Expand Down Expand Up @@ -55,12 +41,12 @@ security:
anonymous: true

new_api_admin_user:
pattern: "%sylius.security.new_api_route%/admin-user-authentication-token"
provider: sylius_admin_user_provider
pattern: "%sylius.security.new_api_admin_regex%/.*"
provider: sylius_api_admin_user_provider
stateless: true
anonymous: true
json_login:
check_path: "%sylius.security.new_api_route%/admin-user-authentication-token"
check_path: "%sylius.security.new_api_admin_route%/authentication-token"
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
Expand All @@ -70,12 +56,12 @@ security:
- lexik_jwt_authentication.jwt_token_authenticator

new_api_shop_user:
pattern: "%sylius.security.new_api_route%/shop-user-authentication-token"
provider: sylius_shop_user_provider
pattern: "%sylius.security.new_api_shop_regex%/.*"
provider: sylius_api_shop_user_provider
stateless: true
anonymous: true
json_login:
check_path: "%sylius.security.new_api_route%/shop-user-authentication-token"
check_path: "%sylius.security.new_api_shop_route%/authentication-token"
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
Expand All @@ -84,15 +70,6 @@ security:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

new_api:
pattern: "%sylius.security.new_api_regex%/*"
provider: sylius_api_chain_provider
stateless: true
anonymous: lazy
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
context: shop
Expand Down Expand Up @@ -124,7 +101,11 @@ security:
anonymous: true

dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

image_resolver:
pattern: ^/media/cache/resolve
security: false

access_control:
Expand All @@ -134,15 +115,16 @@ security:
- { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }

- { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }

- { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY }

- { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
- { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS }
- { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }

- { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
- { path: "%sylius.security.new_api_admin_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER }
- { path: "%sylius.security.new_api_shop_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY }
Empty file.
3 changes: 0 additions & 3 deletions tests/Application/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en_US

services:

4 changes: 2 additions & 2 deletions tests/Application/config/services_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ imports:
- { resource: "../../Behat/Resources/services.xml" }
- { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" }

# workaround needed for strange "test.client.history" problem
# see https://github.com/FriendsOfBehat/SymfonyExtension/issues/88
services:
# workaround needed for strange "test.client.history" problem
# see https://github.com/FriendsOfBehat/SymfonyExtension/issues/88
Symfony\Component\BrowserKit\AbstractBrowser: '@test.client'

webgriffe_sylius_akeneo.api_client:
Expand Down
6 changes: 0 additions & 6 deletions tests/Application/config/sylius/1.10/bundles.php

This file was deleted.

8 changes: 0 additions & 8 deletions tests/Application/config/sylius/1.8/bundles.php

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Application/config/sylius/1.8/packages/_sylius.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading