Skip to content

Commit 22fabf6

Browse files
author
Maxime Leclercq
committed
feat: use the sylius test application
1 parent 41b04c8 commit 22fabf6

38 files changed

+113
-146
lines changed

Makefile

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
.DEFAULT_GOAL := help
22
SHELL=/bin/bash
3-
APP_DIR=tests/Application
4-
SYLIUS_VERSION=2.1.0
5-
SYMFONY=cd ${APP_DIR} && symfony
3+
APP_DIR=vendor/sylius/test-application
4+
SYMFONY=symfony
65
COMPOSER=symfony composer
7-
CONSOLE=${SYMFONY} console
6+
CONSOLE=${SYMFONY} php vendor/bin/console
87
export COMPOSE_PROJECT_NAME=rich-editor
98
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
109
COMPOSE=docker compose
@@ -21,9 +20,7 @@ up: docker.up server.start ## Up the project (start docker, start symfony server
2120
stop: server.stop docker.stop ## Stop the project (stop docker, stop symfony server)
2221
down: server.stop docker.down ## Down the project (removes docker containers, stop symfony server)
2322

24-
reset: ## Stop docker and remove dependencies
25-
${MAKE} docker.down || true
26-
rm -rf ${APP_DIR}
23+
reset: down ## Stop docker and remove dependencies
2724
rm -rf node_modules yarn.lock vendor composer.lock
2825
.PHONY: reset
2926

@@ -59,33 +56,12 @@ ${APP_DIR}/node_modules: yarn.install
5956
### TEST APPLICATION
6057
### ¯¯¯¯¯
6158

62-
application: .php-version php.ini ${APP_DIR} setup_application ${APP_DIR}/docker-compose.yaml
63-
64-
${APP_DIR}:
65-
(${COMPOSER} create-project --no-interaction --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="~${SYLIUS_VERSION}" ${APP_DIR})
66-
67-
setup_application:
68-
rm -f ${APP_DIR}/yarn.lock
69-
(cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}')
70-
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
71-
(cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev)
72-
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
73-
(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"]')
74-
(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
75-
$(MAKE) ${APP_DIR}/.php-version
76-
$(MAKE) ${APP_DIR}/php.ini
77-
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
78-
$(MAKE) apply_dist
79-
(cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
80-
rm -rf ${APP_DIR}/var/cache
81-
59+
application: .php-version php.ini dependencies apply_dist ${APP_DIR}/docker-compose.yaml
60+
.PHONY: application
8261

8362
${APP_DIR}/docker-compose.yaml:
84-
rm -f ${APP_DIR}/docker-compose.yml
85-
rm -f ${APP_DIR}/docker-compose.yaml
86-
rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker
87-
rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker
88-
ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
63+
rm -f ${APP_DIR}/{docker-compose.yml,docker-compose.yaml,compose.yml,compose.override.dist.yml} # Remove all Sylius files about Docker
64+
ln -s ../../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
8965
.PHONY: ${APP_DIR}/docker-compose.yaml
9066

9167
${APP_DIR}/.php-version: .php-version
@@ -136,19 +112,19 @@ test.container: ## Lint the symfony container
136112
${CONSOLE} lint:container
137113

138114
test.yaml: ## Lint the symfony Yaml files
139-
${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags
115+
${CONSOLE} lint:yaml src/Resources/config tests/TestApplication/config --parse-tags
140116

141117
test.schema: ## Validate MySQL Schema
142118
${CONSOLE} doctrine:schema:validate
143119

144120
test.twig: ## Validate Twig templates
145-
${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/
121+
${CONSOLE} lint:twig --no-debug src/Resources/views/ tests/TestApplication/templates/
146122

147123
###
148124
### SYLIUS
149125
### ¯¯¯¯¯¯
150126

151-
sylius: dependencies sylius.database sylius.fixtures sylius.assets messenger.setup ## Install Sylius
127+
sylius: sylius.database sylius.fixtures sylius.assets messenger.setup ## Install Sylius
152128
.PHONY: sylius
153129

154130
sylius.database: ## Setup the database
@@ -199,10 +175,10 @@ docker.dc: ## Run docker-compose command. Use ARGS="" to pass parameters to dock
199175
.PHONY: docker.dc
200176

201177
server.start: ## Run the local webserver using Symfony
202-
${SYMFONY} local:server:start -d
178+
${SYMFONY} local:server:start -d --dir=${APP_DIR}/public
203179

204180
server.stop: ## Stop the local webserver
205-
${SYMFONY} local:server:stop
181+
${SYMFONY} local:server:stop --dir=${APP_DIR}/public
206182

207183
###
208184
### HELP

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ composer require monsieurbiz/sylius-media-manager-plugin="^2.0"
9898
### Update your form type
9999
100100
To make a field use the rich editor, you must use the `RichEditorType` type for it.
101-
We have an example of implementation in the [file for the test application](/dist/src/Form/Extension/ProductTypeExtension.php).
101+
We have an example of implementation in the [file for the test application](/test/src/Form/Extension/ProductTypeExtension.php).
102102
103103
If your field has some data already, like some previous text before installing this plugin,
104104
then we will convert it for you as an HTML Element which contains… HTML.
@@ -115,7 +115,7 @@ To display the content of the rich editor field you must call the twig filter:
115115
{{ content | monsieurbiz_richeditor_render_field }}
116116
```
117117

118-
You can see an example in the [file for the test application](/dist/templates/bundles/SyliusShopBundle/Product/Show/Tabs/Details/_description.html.twig)
118+
You can see an example in the [file for the test application](/tests/TestApplication/templates/bundles/SyliusShopBundle/Product/Show/Tabs/Details/_description.html.twig)
119119

120120
### Custom rendering of elements
121121

assets/admin/controllers.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

assets/admin/entrypoint.js

Whitespace-only changes.

assets/shop/controllers.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

assets/shop/entrypoint.js

Whitespace-only changes.

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"phpstan/phpstan-doctrine": "^1.3.2",
1919
"phpstan/phpstan-webmozart-assert": "^1.1",
2020
"phpunit/phpunit": "^10.5",
21-
"phpmd/phpmd": "^2.15"
21+
"phpmd/phpmd": "^2.15",
22+
"sylius/test-application": "2.1.x-dev"
2223
},
2324
"suggest": {
2425
"monsieurbiz/sylius-media-manager-plugin": "To use the media manager in the ui elements"
@@ -32,6 +33,11 @@
3233
"MonsieurBiz\\SyliusRichEditorPlugin\\": "src/"
3334
}
3435
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Tests\\MonsieurBiz\\SyliusRichEditorPlugin\\TestApplication\\": "tests/TestApplication/src/"
39+
}
40+
},
3541
"scripts": {
3642
"auto-scripts": {
3743
"cache:clear": "symfony-cmd",
@@ -50,15 +56,17 @@
5056
"symfony": {
5157
"docker": false,
5258
"endpoint": ["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", "flex://defaults"]
53-
}
59+
},
60+
"public-dir": "vendor/sylius/test-application/public"
5461
},
5562
"config": {
5663
"allow-plugins": {
5764
"symfony/thanks": true,
5865
"symfony/flex": true,
5966
"dealerdirect/phpcodesniffer-composer-installer": true,
6067
"ergebnis/composer-normalize": true,
61-
"php-http/discovery": true
68+
"php-http/discovery": true,
69+
"symfony/runtime": true
6270
}
6371
}
6472
}

dist/src/Migrations/Version20220621100423.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.0/phpunit.xsd"
55
colors="true"
6-
bootstrap="tests/Application/config/bootstrap.php">
6+
bootstrap="vendor/sylius/test-application/config/bootstrap.php">
77
<testsuites>
88
<testsuite name="MonsieurBizSyliusRichEditorPlugin Test Suite">
99
<directory>tests/Unit</directory>
1010
</testsuite>
1111
</testsuites>
1212

1313
<php>
14-
<server name="KERNEL_CLASS_PATH" value="/tests/Application/src/Kernel.php" />
14+
<server name="KERNEL_CLASS_PATH" value="Sylius\TestApplication\Kernel" />
1515
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
1616

1717
<env name="APP_ENV" value="test"/>

tests/TestApplication/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
BUNDLES_TO_ENABLE="MonsieurBiz\SyliusRichEditorPlugin\MonsieurBizSyliusRichEditorPlugin"
3+
CONFIGS_TO_IMPORT="../../../../tests/TestApplication/config/config.yaml"
4+
ROUTES_TO_IMPORT="../../../../tests/TestApplication/config/routes.yaml"

0 commit comments

Comments
 (0)