From 9149f11d5c4f8f27075bdd0d6c6449d413377bb2 Mon Sep 17 00:00:00 2001
From: Maxime Huran
Date: Wed, 10 Jul 2024 14:25:02 +0200
Subject: [PATCH] Add Sylius 1.13 compatibility
---
.github/workflows/recipe.yaml | 75 ++++++++-----------
.github/workflows/security.yaml | 37 +++++----
.github/workflows/tests.yaml | 65 ++++++++--------
.php-cs-fixer.dist.php | 8 +-
Makefile | 35 ++++-----
README.md | 35 +++++++--
composer.json | 57 ++++----------
dist/.env.dev | 3 -
dist/.env.local | 1 +
dist/src/Migrations/Version20220406160423.php | 71 ------------------
docker-compose.yaml.dist | 1 -
phpstan.neon | 12 +--
phpunit.xml.dist | 55 ++++++++++++++
recipes/1.0-dev | 1 -
.../packages/monsieurbiz_settings_plugin.yaml | 2 -
.../routes/monsieurbiz_settings_plugin.yaml | 4 -
recipes/1.0/manifest.json | 10 ---
src/Entity/Setting/Setting.php | 28 +++----
src/Migrations/Version20240710130300.php | 40 ++++++++++
tests/Unit/.gitkeep | 0
20 files changed, 258 insertions(+), 282 deletions(-)
delete mode 100644 dist/.env.dev
create mode 100644 dist/.env.local
delete mode 100644 dist/src/Migrations/Version20220406160423.php
create mode 100644 phpunit.xml.dist
delete mode 120000 recipes/1.0-dev
delete mode 100644 recipes/1.0/config/packages/monsieurbiz_settings_plugin.yaml
delete mode 100644 recipes/1.0/config/routes/monsieurbiz_settings_plugin.yaml
delete mode 100644 recipes/1.0/manifest.json
create mode 100644 src/Migrations/Version20240710130300.php
create mode 100644 tests/Unit/.gitkeep
diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml
index 9a0b4a3b8..44e3d2351 100644
--- a/.github/workflows/recipe.yaml
+++ b/.github/workflows/recipe.yaml
@@ -9,25 +9,29 @@ jobs:
recipe:
- name: Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}
-
runs-on: ubuntu-latest
- env:
- SYMFONY_ENDPOINT: http://127.0.0.1/
-
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2']
- sylius: ['~1.10.0', '~1.11.0', '~1.12.0']
+ sylius: ["~1.11.0", "~1.12.0", "~1.13.0"]
+ exclude:
+ - php: '8.2'
+ sylius: '~1.11.0'
+ - php: '8.0'
+ sylius: '~1.12.0'
+ - php: '8.0'
+ sylius: '~1.13.0'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
+ extensions: gd, intl, json
ini-values: date.timezone=UTC
+ tools: symfony-cli
- name: Set project php-version
run: |
@@ -37,33 +41,24 @@ jobs:
with:
path: plugin
- # Run the server at the start so it can download the recipes!
- - name: Run standalone symfony flex server
- run: |
- echo ${{ github.token }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- docker run --rm --name flex -d -v $PWD/plugin/recipes:/var/www/flex/var/repo/private/monsieurbiz/sylius-settings-plugin -p 80:80 docker.pkg.github.com/monsieurbiz/docker/symfony-flex-server:latest contrib official
- docker ps
-
- - run: mkdir -p /home/runner/{.composer/cache,.config/composer}
-
- - name: Determine composer cache directory
- id: composer-cache-directory
- working-directory: plugin
- run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
+ - name: Determine composer cache directory
+ id: composer-cache-directory
+ working-directory: plugin
+ run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- - name: Cache dependencies installed with composer
- uses: actions/cache@v3
- id: cache-composer
- with:
- path: ${{ steps.composer-cache-directory.outputs.directory }}
- key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ hashFiles('**/composer.json') }}
- restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
+ id: cache-composer
+ with:
+ path: ${{ steps.composer-cache-directory.outputs.directory }}
+ key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ hashFiles('**/composer.json') }}
+ restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-
- - name: Ensure that composer cache directory exists
- run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
+ - name: Ensure that composer cache directory exists
+ run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
- - name: Composer Github Auth
- run: composer config -g github-oauth.github.com ${{ github.token }}
+ - name: Composer Github Auth
+ run: composer config -g github-oauth.github.com ${{ github.token }}
- name: Create Sylius-Standard project without install
run: |
@@ -79,20 +74,14 @@ jobs:
working-directory: ./sylius
run: |
composer config --no-plugins allow-plugins true
+ composer config --no-plugins extra.symfony.allow-contrib true
+ composer config --no-plugins secure-http false
+ composer config --no-plugins --unset platform.php
+ composer config --no-plugins extra.symfony.docker false
+ composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
composer config repositories.plugin '{"type": "path", "url": "../plugin/"}'
- composer config extra.symfony.allow-contrib true
- composer config secure-http false
- composer config --unset platform.php
- - name: Require plugin without install
+ - name: Require plugin & install all dependencies
working-directory: ./sylius
run: |
- composer require --no-install --no-scripts monsieurbiz/sylius-settings-plugin="*@dev"
-
- - name: Composer install
- working-directory: ./sylius
- run: |
- composer install
-
- - name: Show flex server logs
- run: docker logs --tail 100 flex
+ composer require monsieurbiz/sylius-settings-plugin="*@dev"
diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml
index 0522893de..c100cfa13 100644
--- a/.github/workflows/security.yaml
+++ b/.github/workflows/security.yaml
@@ -7,15 +7,13 @@ on:
jobs:
security:
-
- name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- php: ['8.0', '8.1', '8.2']
+ php: ['8.1', '8.2']
steps:
- uses: actions/checkout@v3
@@ -24,31 +22,32 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- ini-values: date.timezone=UTC
+ extensions: gd, intl, json
- name: Set project php-version
run: |
- echo ${{ matrix.php }} > .php-version
+ echo "${{ matrix.php }}" > .php-version
- - name: Determine composer cache directory
- id: composer-cache-directory
- run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
+ - name: Determine composer cache directory
+ id: composer-cache-directory
+ run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- - name: Cache dependencies installed with composer
- uses: actions/cache@v3
- id: cache-composer
- with:
- path: ${{ steps.composer-cache-directory.outputs.directory }}
- key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
- restore-keys: composer2-php:${{ matrix.php }}-
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
+ id: cache-composer
+ with:
+ path: ${{ steps.composer-cache-directory.outputs.directory }}
+ key: composer2-php:${{ matrix.php }}-${{ github.sha }}
+ restore-keys: composer2-php:${{ matrix.php }}-
- - name: Ensure that composer cache directory exists
- run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
+ - name: Ensure that composer cache directory exists
+ run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
- - name: Composer Github Auth
- run: composer config -g github-oauth.github.com ${{ github.token }}
+ - name: Composer Github Auth
+ run: composer config -g github-oauth.github.com ${{ github.token }}
- name: Install PHP dependencies
run: composer update --prefer-dist
- uses: symfonycorp/security-checker-action@v4
+
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 42c050297..877ce6a6a 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -8,15 +8,13 @@ on:
jobs:
php:
-
- name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- php: ['8.0', '8.1', '8.2']
+ php: ['8.1', '8.2']
env:
SYMFONY_ARGS: --no-tls
@@ -24,49 +22,48 @@ jobs:
DOCKER_INTERACTIVE_ARGS: -t
steps:
- - uses: actions/checkout@v3
-
+ - uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: gd, intl, json
+ ini-values: date.timezone=UTC
+ tools: symfony-cli
+
+ - name: Set project php-version
+ run: |
+ echo "${{ matrix.php }}" > .php-version
+
+ - name: Determine composer cache directory
+ id: composer-cache-directory
+ run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
+
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
+ id: cache-composer
+ with:
+ path: ${{ steps.composer-cache-directory.outputs.directory }}
+ key: composer2-php:${{ matrix.php }}-${{ github.sha }}
+ restore-keys: composer2-php:${{ matrix.php }}-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php }}
- ini-values: date.timezone=UTC
- tools: symfony-cli
-
- - name: Set project php-version
- run: |
- echo ${{ matrix.php }} > .php-version
-
- - name: Determine composer cache directory
- id: composer-cache-directory
- run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
-
- - name: Cache dependencies installed with composer
- uses: actions/cache@v3
- id: cache-composer
- with:
- path: ${{ steps.composer-cache-directory.outputs.directory }}
- key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
- restore-keys: composer2-php:${{ matrix.php }}-
-
- - name: Ensure that composer cache directory exists
- run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
+ - name: Ensure that composer cache directory exists
+ run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}
- - name: Composer Github Auth
- run: composer config -g github-oauth.github.com ${{ github.token }}
+ - name: Composer Github Auth
+ run: composer config -g github-oauth.github.com ${{ github.token }}
- run: make install
- - run: make sylius.fixtures.local
-
- run: make test.composer
- run: make test.phpcs
+ - run: make test.phpunit
+
- run: make test.phpstan
- run: make test.phpmd
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 29f25c04d..765b7acc7 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -60,7 +60,7 @@
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'comment_to_phpdoc' => true,
- 'compact_nullable_typehint' => true,
+ 'compact_nullable_type_declaration' => true,
'concat_space' => [
'spacing' => 'one',
],
@@ -120,7 +120,7 @@
],
'native_constant_invocation' => true,
'native_function_casing' => true,
- 'new_with_braces' => true,
+ 'new_with_parentheses' => true,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => true,
@@ -159,14 +159,14 @@
'no_short_bool_cast' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
- 'no_spaces_inside_parenthesis' => true,
+ 'spaces_inside_parentheses' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_unset_cast' => true,
'no_unneeded_control_parentheses' => true,
- 'no_unneeded_curly_braces' => true,
+ 'no_unneeded_braces' => true,
'no_unneeded_final_method' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
diff --git a/Makefile b/Makefile
index eb16aa52a..782df10bc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,13 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
-SYLIUS_VERSION=1.12.0
+SYLIUS_VERSION=1.13.0
SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
export COMPOSE_PROJECT_NAME=settings
+export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusSettingsPlugin\\Migrations
+export USER_UID=$(shell id -u)
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
COMPOSE=docker-compose
YARN=yarn
@@ -70,18 +72,21 @@ setup_application:
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
(cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev)
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
+ (cd ${APP_DIR} && ${COMPOSER} config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]')
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
$(MAKE) ${APP_DIR}/.php-version
$(MAKE) ${APP_DIR}/php.ini
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
$(MAKE) apply_dist
- (cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
+ (cd ${APP_DIR} && ${COMPOSER} require --no-progress --no-interaction monsieurbiz/${PLUGIN_NAME}="*@dev")
rm -rf ${APP_DIR}/var/cache
${APP_DIR}/docker-compose.yaml:
rm -f ${APP_DIR}/docker-compose.yml
rm -f ${APP_DIR}/docker-compose.yaml
+ rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker
+ rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker
ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
.PHONY: ${APP_DIR}/docker-compose.yaml
@@ -106,7 +111,7 @@ apply_dist:
### TESTS
### ¯¯¯¯¯
-test.all: test.composer test.phpstan test.phpmd test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once
+test.all: test.composer test.phpstan test.phpmd test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once
test.composer: ## Validate composer.json
${COMPOSER} validate --strict
@@ -117,6 +122,9 @@ test.phpstan: ## Run PHPStan
test.phpmd: ## Run PHPMD
${COMPOSER} phpmd
+test.phpunit: ## Run PHPUnit
+ ${COMPOSER} phpunit
+
test.phpspec: ## Run PHPSpec
${COMPOSER} phpspec
@@ -130,7 +138,7 @@ test.container: ## Lint the symfony container
${CONSOLE} lint:container
test.yaml: ## Lint the symfony Yaml files
- ${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config
+ ${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags
test.schema: ## Validate MySQL Schema
${CONSOLE} doctrine:schema:validate
@@ -153,9 +161,6 @@ sylius.database: ## Setup the database
sylius.fixtures: ## Run the fixtures
${CONSOLE} sylius:fixtures:load -n default
-sylius.fixtures.local: ## Run the local fixtures (for testing purpose)
- ${CONSOLE} sylius:fixtures:load -n local
-
sylius.assets: ## Install all assets with symlinks
${CONSOLE} assets:install --symlink
${CONSOLE} sylius:install:assets
@@ -164,6 +169,9 @@ sylius.assets: ## Install all assets with symlinks
messenger.setup: ## Setup Messenger transports
${CONSOLE} messenger:setup-transports
+doctrine.diff: ## Doctrine diff
+ ${CONSOLE} doctrine:migration:diff --namespace="${MIGRATIONS_NAMESPACE}"
+
###
### PLATFORM
### ¯¯¯¯¯¯¯¯
@@ -201,19 +209,6 @@ server.start: ## Run the local webserver using Symfony
server.stop: ## Stop the local webserver
${SYMFONY} local:server:stop
-
-ifdef CODESPACES
-###
-### GITHUB CODESPACES
-### ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
-
-codespace.hostname: ${APP_DIR}/.env.local ## Init the SYLIUS_FIXTURES_HOSTNAME variable in .env.local
- echo SYLIUS_FIXTURES_HOSTNAME=${CODESPACE_NAME}-8000.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN} >> ${APP_DIR}/.env.local
-endif
-
-${APP_DIR}/.env.local:
- touch ${APP_DIR}/.env.local
-
###
### HELP
### ¯¯¯¯
diff --git a/README.md b/README.md
index d949e0a0a..c83d5ebc4 100644
--- a/README.md
+++ b/README.md
@@ -3,16 +3,29 @@
Settings for Sylius
[![Settings Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusSettingsPlugin?public)](https://github.com/monsieurbiz/SyliusSettingsPlugin/blob/master/LICENSE.txt)
-[![Tests](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions/workflows/tests.yaml/badge.svg?branch=master&event=push)](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions/workflows/tests.yaml)
-[![Security](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions/workflows/security.yaml/badge.svg?branch=master&event=push)](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions/workflows/security.yaml)
+[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusSettingsPlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions?query=workflow%3ATests)
+[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusSettingsPlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions?query=workflow%3ASecurity)
+[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusSettingsPlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusSettingsPlugin/actions?query=workflow%3ASecurity)
This plugin gives you the ability to have Plugins oriented settings in your favorite e-commerce platform, Sylius.
![Screenshot of the admin panel in Settings section](/docs/images/screenshot01.png)
+## Compatibility
+
+| Sylius Version | PHP Version |
+|---|---|
+| 1.11 | 8.0 - 8.1 |
+| 1.12 | 8.1 - 8.2 |
+| 1.13 | 8.1 - 8.2 |
+
## Installation
-Install the plugin via composer:
+If you want to use our recipes, you can configure your composer.json by running:
+
+```bash
+composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
+```
```bash
composer require monsieurbiz/sylius-settings-plugin
@@ -31,9 +44,19 @@ return [
];
```
-Copy the plugin configuration files in your `config` folder:
-```bash
-cp -Rv vendor/monsieurbiz/sylius-settings-plugin/recipes/1.0-dev/config/ config
+Then create the config file in `config/packages/monsieurbiz_settings_plugin.yaml` :
+
+```yaml
+imports:
+ - { resource: "@MonsieurBizSyliusSettingsPlugin/Resources/config/config.yaml" }
+```
+
+Finally import the routes in `config/routes/monsieurbiz_settings_plugin.yaml` :
+
+```yaml
+monsieurbiz_sylius_settings_admin:
+ resource: "@MonsieurBizSyliusSettingsPlugin/Resources/config/routes/admin.yaml"
+ prefix: /%sylius_admin.path_name%
```
diff --git a/composer.json b/composer.json
index 37a58a371..a5e00b000 100644
--- a/composer.json
+++ b/composer.json
@@ -6,45 +6,16 @@
"license": "MIT",
"require": {
"php": "^8.0",
- "ext-mbstring": "*",
- "ext-json": "*",
- "sylius/sylius": ">=1.10 <1.13",
- "symfony/cache": "^5.4.28 || ^6.0 || ^7.0"
+ "sylius/sylius": ">=1.11 <1.14"
},
"require-dev": {
- "behat/behat": "^3.6.1",
- "behat/mink-selenium2-driver": "^1.4",
- "dmore/behat-chrome-extension": "^1.3",
- "dmore/chrome-mink-driver": "^2.7",
- "doctrine/data-fixtures": "^1.4",
- "ergebnis/composer-normalize": "^2.5",
- "friends-of-behat/mink": "^1.8",
- "friends-of-behat/mink-browserkit-driver": "^1.4",
- "friends-of-behat/mink-extension": "^2.4",
- "friends-of-behat/page-object-extension": "^0.3",
- "friends-of-behat/symfony-extension": "^2.1",
- "friends-of-behat/variadic-extension": "^1.3",
- "hwi/oauth-bundle": "^1.1",
- "lchrusciel/api-test-case": "^5.0",
- "matthiasnoback/symfony-config-test": "^4.2",
- "matthiasnoback/symfony-dependency-injection-test": "^4.1",
- "mikey179/vfsstream": "^1.6",
- "mockery/mockery": "@stable",
- "pamil/prophecy-common": "@stable",
- "phpspec/phpspec": "@stable",
- "phpstan/phpstan": "@stable",
- "phpstan/phpstan-doctrine": "@stable",
- "phpstan/phpstan-webmozart-assert": "@stable",
- "psalm/plugin-mockery": "@stable",
- "psr/event-dispatcher": "@stable",
- "symfony/browser-kit": "@stable",
- "symfony/debug-bundle": "@stable",
- "symfony/dotenv": "@stable",
- "symfony/flex": "@stable",
- "symfony/web-profiler-bundle": "@stable",
- "phpmd/phpmd": "@stable",
- "friendsofphp/php-cs-fixer": "@stable",
- "symfony/twig-bridge": "^5.4"
+ "friendsofphp/php-cs-fixer": "^3.16",
+ "phpspec/phpspec": "^7.0",
+ "phpstan/phpstan": "^1.8.4",
+ "phpstan/phpstan-doctrine": "^1.3.2",
+ "phpstan/phpstan-webmozart-assert": "^1.1",
+ "phpunit/phpunit": "^10.5",
+ "phpmd/phpmd": "^2.15"
},
"prefer-stable": true,
"autoload": {
@@ -57,25 +28,27 @@
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
- "phpcs": "php-cs-fixer fix --using-cache=no",
+ "phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=no",
"phpstan": "phpstan analyse -c phpstan.neon src/",
"phpmd": "phpmd --exclude Migrations/* src/ ansi phpmd.xml",
+ "phpunit": "phpunit",
"phpspec": "phpspec run"
},
"extra": {
"branch-alias": {
- "dev-master": "1.0-dev"
+ "dev-master": "1.1-dev"
},
"symfony": {
- "allow-contrib": "true"
+ "docker": false,
+ "endpoint": ["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", "flex://defaults"]
}
},
"config": {
"allow-plugins": {
- "dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
- "ergebnis/composer-normalize": true,
"symfony/flex": true,
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "ergebnis/composer-normalize": true,
"php-http/discovery": true
}
}
diff --git a/dist/.env.dev b/dist/.env.dev
deleted file mode 100644
index 7cfbdf809..000000000
--- a/dist/.env.dev
+++ /dev/null
@@ -1,3 +0,0 @@
-APP_ENV=dev
-APP_DEBUG=1
-SYLIUS_FIXTURES_HOSTNAME=sylius.wip
diff --git a/dist/.env.local b/dist/.env.local
new file mode 100644
index 000000000..6c1a99ee5
--- /dev/null
+++ b/dist/.env.local
@@ -0,0 +1 @@
+SYLIUS_FIXTURES_HOSTNAME=${SYMFONY_DEFAULT_ROUTE_HOST:-localhost}
diff --git a/dist/src/Migrations/Version20220406160423.php b/dist/src/Migrations/Version20220406160423.php
deleted file mode 100644
index 2e4e024a7..000000000
--- a/dist/src/Migrations/Version20220406160423.php
+++ /dev/null
@@ -1,71 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE.txt
- * file that was distributed with this source code.
- */
-
-declare(strict_types=1);
-
-namespace App\Migrations;
-
-use Doctrine\DBAL\Schema\Schema;
-use Doctrine\Migrations\AbstractMigration;
-
-/**
- * Auto-generated Migration: Please modify to your needs!
- */
-final class Version20220406160423 extends AbstractMigration
-{
- public function getDescription(): string
- {
- return 'Change length of messenger_messages.queue_name column and create missing indexes, cf https://github.com/Sylius/Sylius/issues/13838';
- }
-
- public function up(Schema $schema): void
- {
- if ($schema->hasTable('messenger_messages')) {
- $this->addSql('ALTER TABLE messenger_messages CHANGE queue_name queue_name VARCHAR(190) NOT NULL');
- if (!$this->tableHasIndexOnColumns('messenger_messages', ['queue_name'])) {
- $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
- }
- if (!$this->tableHasIndexOnColumns('messenger_messages', ['available_at'])) {
- $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
- }
- }
- }
-
- public function down(Schema $schema): void
- {
- if ($schema->hasTable('messenger_messages')) {
- if ($this->tableHasIndexOnColumns('messenger_messages', ['queue_name'])) {
- $this->addSql('DROP INDEX IDX_75EA56E0FB7336F0 ON messenger_messages');
- }
- if ($this->tableHasIndexOnColumns('messenger_messages', ['available_at'])) {
- $this->addSql('DROP INDEX IDX_75EA56E0E3BD61CE ON messenger_messages');
- }
- $this->addSql('ALTER TABLE messenger_messages CHANGE queue_name queue_name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
- }
- }
-
- private function tableHasIndexOnColumns(string $table, array $columns): bool
- {
- $indexes = $this->connection->getSchemaManager()->listTableIndexes($table);
- foreach ($indexes as $index) {
- foreach ($index->getColumns() as $column) {
- // Another column exists in index
- if (($key = array_search($column, $columns, true)) === false) {
- continue 2;
- }
- unset($columns[$key]);
- }
- }
-
- // Table has all columns in index if the given array in empty at the end
- return empty($columns);
- }
-}
diff --git a/docker-compose.yaml.dist b/docker-compose.yaml.dist
index 955683cc6..24d6f0cb0 100644
--- a/docker-compose.yaml.dist
+++ b/docker-compose.yaml.dist
@@ -1,4 +1,3 @@
-version: '3.8'
services:
database:
image: mysql:8.0
diff --git a/phpstan.neon b/phpstan.neon
index f47472844..122773da1 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,16 +1,8 @@
-includes:
- - vendor/phpstan/phpstan-doctrine/extension.neon
- - vendor/phpstan/phpstan-webmozart-assert/extension.neon
-
parameters:
level: max
paths:
- %rootDir%/src/
- checkMissingIterableValueType: false
-
- checkGenericClassInNonGenericObjectType: false
-
excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'
@@ -18,3 +10,7 @@ parameters:
# Test dependencies
- 'tests/Application/**/*'
+
+ ignoreErrors:
+ - identifier: missingType.generics
+ - identifier: missingType.iterableValue
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 000000000..c52dc1b2c
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,55 @@
+
+
+
+
+
+ tests/Unit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/recipes/1.0-dev b/recipes/1.0-dev
deleted file mode 120000
index 9f8e9b69a..000000000
--- a/recipes/1.0-dev
+++ /dev/null
@@ -1 +0,0 @@
-1.0
\ No newline at end of file
diff --git a/recipes/1.0/config/packages/monsieurbiz_settings_plugin.yaml b/recipes/1.0/config/packages/monsieurbiz_settings_plugin.yaml
deleted file mode 100644
index 6fb372d95..000000000
--- a/recipes/1.0/config/packages/monsieurbiz_settings_plugin.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-imports:
- - { resource: "@MonsieurBizSyliusSettingsPlugin/Resources/config/config.yaml" }
diff --git a/recipes/1.0/config/routes/monsieurbiz_settings_plugin.yaml b/recipes/1.0/config/routes/monsieurbiz_settings_plugin.yaml
deleted file mode 100644
index 5503d8f49..000000000
--- a/recipes/1.0/config/routes/monsieurbiz_settings_plugin.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-monsieurbiz_sylius_settings_admin:
- resource: "@MonsieurBizSyliusSettingsPlugin/Resources/config/routes/admin.yaml"
- prefix: /%sylius_admin.path_name%
-
diff --git a/recipes/1.0/manifest.json b/recipes/1.0/manifest.json
deleted file mode 100644
index 950ebfd44..000000000
--- a/recipes/1.0/manifest.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "bundles": {
- "MonsieurBiz\\SyliusSettingsPlugin\\MonsieurBizSyliusSettingsPlugin": [
- "all"
- ]
- },
- "copy-from-recipe": {
- "config/": "%CONFIG_DIR%/"
- }
-}
diff --git a/src/Entity/Setting/Setting.php b/src/Entity/Setting/Setting.php
index fb389850e..c0bca1a35 100644
--- a/src/Entity/Setting/Setting.php
+++ b/src/Entity/Setting/Setting.php
@@ -35,22 +35,22 @@ class Setting implements SettingInterface
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
- private ?int $id;
+ protected ?int $id;
/**
* @ORM\Column(type="string", nullable=false)
*/
- private ?string $vendor;
+ protected ?string $vendor;
/**
* @ORM\Column(type="string", nullable=false)
*/
- private ?string $plugin;
+ protected ?string $plugin;
/**
* @ORM\Column(type="string", nullable=false)
*/
- private ?string $path;
+ protected ?string $path;
/**
* @ORM\ManyToOne(targetEntity="\Sylius\Component\Core\Model\ChannelInterface")
@@ -58,52 +58,52 @@ class Setting implements SettingInterface
*
* @Assert\Type(type="\Sylius\Component\Core\Model\ChannelInterface")
*/
- private ?ChannelInterface $channel;
+ protected ?ChannelInterface $channel;
/**
* @ORM\Column(name="locale_code", type="string", length=5, nullable=true)
*/
- private ?string $localeCode;
+ protected ?string $localeCode;
/**
* @ORM\Column(name="storage_type", type="string", length=10, nullable=false)
*/
- private ?string $storageType = null;
+ protected ?string $storageType = null;
/**
* @ORM\Column(name="text_value", type="text", length=65535, nullable=true)
*/
- private ?string $textValue;
+ protected ?string $textValue;
/**
* @ORM\Column(name="boolean_value", type="boolean", nullable=true)
*/
- private ?bool $booleanValue;
+ protected ?bool $booleanValue;
/**
* @ORM\Column(name="integer_value", type="integer", nullable=true)
*/
- private ?int $integerValue;
+ protected ?int $integerValue;
/**
* @ORM\Column(name="float_value", type="float", nullable=true)
*/
- private ?float $floatValue;
+ protected ?float $floatValue;
/**
* @ORM\Column(name="datetime_value", type="datetime", nullable=true)
*/
- private ?DateTimeInterface $datetimeValue;
+ protected ?DateTimeInterface $datetimeValue;
/**
* @ORM\Column(name="date_value", type="date", nullable=true)
*/
- private ?DateTimeInterface $dateValue;
+ protected ?DateTimeInterface $dateValue;
/**
* @ORM\Column(name="json_value", type="json", nullable=true)
*/
- private ?array $jsonValue;
+ protected ?array $jsonValue;
/**
* @var DateTimeInterface|null
diff --git a/src/Migrations/Version20240710130300.php b/src/Migrations/Version20240710130300.php
new file mode 100644
index 000000000..5a117ccea
--- /dev/null
+++ b/src/Migrations/Version20240710130300.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE.txt
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace MonsieurBiz\SyliusSettingsPlugin\Migrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20240710130300 extends AbstractMigration
+{
+ public function getDescription(): string
+ {
+ return '';
+ }
+
+ public function up(Schema $schema): void
+ {
+ // this up() migration is auto-generated, please modify it to your needs
+ $this->addSql('ALTER TABLE mbiz_settings_setting CHANGE json_value json_value JSON DEFAULT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('ALTER TABLE mbiz_settings_setting CHANGE json_value json_value JSON DEFAULT NULL');
+ }
+}
diff --git a/tests/Unit/.gitkeep b/tests/Unit/.gitkeep
new file mode 100644
index 000000000..e69de29bb