Skip to content

Commit 2ec91bb

Browse files
authored
Merge pull request #176 from synolia/feature/test-application
[Tests] Sylius TestApplication
2 parents 5a0546a + ec8b57f commit 2ec91bb

33 files changed

Lines changed: 237 additions & 373 deletions

.github/workflows/sylius.yaml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ jobs:
1919
matrix:
2020
php:
2121
- 8.2
22+
- 8.4
2223
sylius:
2324
- 2.1.0
25+
- 2.0.0
2426
symfony:
2527
- 6.4
28+
- 7.3
2629
node:
27-
- 18.x
30+
- 20.x
2831
env:
2932
APP_ENV: test
3033
package-name: payplug/sylius-payplug-plugin
@@ -43,9 +46,6 @@ jobs:
4346
uses: actions/setup-node@v3
4447
with:
4548
node-version: '${{ matrix.node }}'
46-
-
47-
name: 'Wkhtmltopdf - Install'
48-
run: "sudo apt-get update\nsudo apt-get install xvfb libfontconfig wkhtmltopdf\nprintf '#!/bin/bash\\nxvfb-run -a --server-args=\"-screen 0, 1024x768x24\" /usr/bin/wkhtmltopdf -q $*' | sudo tee /usr/bin/wkhtmltopdf.sh\nsudo chmod a+x /usr/bin/wkhtmltopdf.sh\nsudo ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf\n"
4949
-
5050
uses: actions/checkout@v3
5151
-
@@ -80,41 +80,32 @@ jobs:
8080
restore-keys: "node-${{ matrix.node }}-yarn-\n"
8181
-
8282
name: 'Install Sylius-Standard and Plugin'
83-
run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }} PHP_VERSION=${{ matrix.php }}'
84-
-
85-
name: 'Output PHP version for Symfony CLI'
86-
working-directory: ./tests/Application
87-
run: 'php -v | head -n 1 | awk ''{ print $2 }'' > .php-version'
83+
run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}'
8884
-
8985
name: 'Install certificates'
90-
working-directory: ./tests/Application
9186
run: 'symfony server:ca:install'
9287
-
9388
name: 'Run Chrome headless'
94-
working-directory: ./tests/Application
9589
run: 'google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server=''direct://'' --proxy-bypass-list=''*'' https://127.0.0.1 > /dev/null 2>&1 &'
9690
-
9791
name: 'Run webserver'
98-
working-directory: ./tests/Application
99-
run: 'symfony server:start --port=8080 --dir=public --daemon'
92+
run: 'symfony server:start --port=8080 --daemon'
10093
id: end-of-setup-sylius
10194
-
10295
name: 'Doctrine Schema Validate - Run'
103-
working-directory: ./tests/Application
104-
run: 'php bin/console doctrine:schema:validate --skip-sync'
96+
run: 'vendor/bin/console doctrine:schema:validate --skip-sync'
10597
-
10698
name: 'Run PHPUnit'
10799
run: 'make phpunit'
108100
if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
109-
-
110-
name: 'Configure Behat'
111-
run: 'make behat-configure'
112-
if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
113-
-
114-
name: 'Run behat'
115-
working-directory: ./tests/Application
116-
run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun'
117-
if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
101+
# -
102+
# name: 'Configure Behat'
103+
# run: 'make behat-configure'
104+
# if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
105+
# -
106+
# name: 'Run behat'
107+
# run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun'
108+
# if: 'always() && steps.end-of-setup-sylius.outcome == ''success'''
118109
-
119110
uses: actions/upload-artifact@v4
120111
if: failure()

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313

1414
/.idea
1515
*.map
16+
17+
/tests/TestApplication/.env.local
18+
/tests/TestApplication/.env.*.local
19+
/var/

Makefile

Lines changed: 16 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,42 @@
11
.DEFAULT_GOAL := help
22
SHELL=/bin/bash
33
COMPOSER_ROOT=composer
4-
TEST_DIRECTORY=tests/Application
5-
CONSOLE=cd tests/Application && php bin/console -e test
6-
COMPOSER=cd tests/Application && composer
7-
YARN=cd tests/Application && yarn
8-
9-
SYLIUS_VERSION=1.12.0
10-
SYMFONY_VERSION=6.1
11-
PHP_VERSION=8.1
4+
TEST_DIRECTORY=tests/TestApplication
5+
CONSOLE=vendor/bin/console
6+
COMPOSER=composer
7+
SYLIUS_VERSION=2.1.0
8+
SYMFONY_VERSION=6.4
129
PLUGIN_NAME=payplug/sylius-payplug-plugin
1310

1411
###
1512
### DEVELOPMENT
1613
### ¯¯¯¯¯¯¯¯¯¯¯
17-
18-
install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.0] [SYMFONY_VERSION=6.1] [PHP_VERSION=8.1]
14+
install: sylius ## Install all dependencies with [SYLIUS_VERSION=2.1.0] [SYMFONY_VERSION=6.4]
1915
.PHONY: install
2016

2117
reset: ## Remove dependencies
22-
ifneq ("$(wildcard tests/Application/bin/console)","")
2318
${CONSOLE} doctrine:database:drop --force --if-exists || true
24-
endif
25-
rm -rf tests/Application
19+
rm -rf vendor
2620
.PHONY: reset
2721

28-
phpunit: phpunit-configure phpunit-run ## Run PHPUnit
22+
phpunit: ## Run PHPUnit tests
23+
./vendor/bin/phpunit
2924
.PHONY: phpunit
3025

3126
###
3227
### OTHER
3328
### ¯¯¯¯¯¯
34-
35-
sylius: sylius-standard install-plugin install-sylius
29+
sylius: install-sylius
3630
.PHONY: sylius
3731

38-
sylius-standard:
39-
ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true)
40-
${COMPOSER_ROOT} create-project sylius/sylius-standard:${SYLIUS_VERSION} ${TEST_DIRECTORY} --no-install --no-scripts
41-
else
42-
${COMPOSER_ROOT} create-project sylius/sylius-standard ${TEST_DIRECTORY} "~${SYLIUS_VERSION}" --no-install --no-scripts
43-
endif
44-
${COMPOSER} config allow-plugins true
45-
ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true)
46-
${COMPOSER} require sylius/sylius:"${SYLIUS_VERSION}"
47-
else
48-
${COMPOSER} require sylius/sylius:"~${SYLIUS_VERSION}"
49-
endif
50-
51-
install-plugin:
52-
${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}'
53-
${COMPOSER} config extra.symfony.allow-contrib true
54-
${COMPOSER} config minimum-stability "dev"
55-
${COMPOSER} config prefer-stable true
56-
${COMPOSER} require "${PLUGIN_NAME}:*" --prefer-source --no-scripts
57-
58-
cp -r install/Application tests
59-
sed -i "4a \ \ \ \ form_themes: ['form/form_gateway_config_row.html.twig']" ${TEST_DIRECTORY}/config/packages/twig.yaml
60-
mkdir -p ${TEST_DIRECTORY}/templates/form/
61-
cp -R src/Resources/views/form/* ${TEST_DIRECTORY}/templates/form/
62-
63-
# As of sylius/refund-plugin 1.2 the folder does not exist anymore
64-
ifneq ($(PHP_VERSION), 8)
65-
mkdir -p ${TEST_DIRECTORY}/templates/bundles/SyliusAdminBundle/
66-
cp -R src/Resources/views/SyliusAdminBundle/* ${TEST_DIRECTORY}/templates/bundles/SyliusAdminBundle/
67-
endif
68-
6932
install-sylius:
70-
#${CONSOLE} sylius:install -n -s default
71-
${CONSOLE} doctrine:database:create -n
72-
${CONSOLE} messenger:setup-transports -n
73-
${CONSOLE} doctrine:migration:migrate -n
74-
${CONSOLE} sylius:fixture:load -n
75-
${YARN} install
76-
${YARN} build
77-
${YARN} gulp
78-
${CONSOLE} translation:extract en PayPlugSyliusPayPlugPlugin --dump-messages
79-
${CONSOLE} translation:extract fr PayPlugSyliusPayPlugPlugin --dump-messages
80-
81-
${CONSOLE} cache:clear
33+
@echo "Installing Sylius ${SYLIUS_VERSION} using TestApplication"
34+
${COMPOSER} config extra.symfony.require "^${SYMFONY_VERSION}"
35+
${COMPOSER} install
36+
${COMPOSER} require --dev sylius/test-application:"^${SYLIUS_VERSION}@alpha" -n -W # TODO: Remove alpha when stable
37+
${COMPOSER} test-application:install
8238

83-
phpunit-configure:
84-
cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml
85-
echo -e "\nMOCK_SERVER_HOST=localhost\nMOCK_SERVER_PORT=8987\n" >> ${TEST_DIRECTORY}/.env.test.local
8639

87-
phpunit-run:
88-
cd ${TEST_DIRECTORY} && ./vendor/bin/phpunit
8940

9041
behat-configure: ## Configure Behat
9142
(cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml)
@@ -101,7 +52,7 @@ grumphp:
10152
vendor/bin/grumphp run
10253

10354
help: SHELL=/bin/bash
104-
help: ## Dislay this help
55+
help: ## Display this help
10556
@IFS=$$'\n'; for line in `grep -h -E '^[a-zA-Z_#-]+:?.*?##.*$$' $(MAKEFILE_LIST)`; do if [ "$${line:0:2}" = "##" ]; then \
10657
echo $$line | awk 'BEGIN {FS = "## "}; {printf "\033[33m %s\033[0m\n", $$2}'; else \
10758
echo $$line | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m%s\n", $$1, $$2}'; fi; \

assets/admin/entrypoint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Mandatory by test application
2+
// whereas it's useless

assets/controllers.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"controllers": {
3+
"@payplug/sylius-payplug-plugin": {
4+
"oney-popin": {
5+
"enabled": true,
6+
"fetch": "lazy",
7+
"autoimport": {
8+
"@payplug/sylius-payplug-plugin/shop/dist/oney_common/index.css": true,
9+
"@payplug/sylius-payplug-plugin/shop/dist/oney_popin/index.css": true
10+
}
11+
},
12+
"integrated-payment": {
13+
"enabled": true,
14+
"fetch": "lazy",
15+
"autoimport": {
16+
"@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true
17+
}
18+
},
19+
"oney-payment": {
20+
"enabled": true,
21+
"fetch": "lazy"
22+
},
23+
"payment-logo": {
24+
"enabled": true,
25+
"fetch": "lazy"
26+
},
27+
"checkout-select-payment": {
28+
"enabled": true,
29+
"fetch": "lazy",
30+
"autoimport": {
31+
"@payplug/sylius-payplug-plugin/shop/dist/payment/index.css": true
32+
}
33+
},
34+
"apple-pay": {
35+
"enabled": true,
36+
"fetch": "lazy"
37+
}
38+
}
39+
},
40+
"entrypoints": []
41+
}

assets/shop/entrypoint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Mandatory by test application
2+
// whereas it's useless

composer.json

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
"description": "PayPlug payment plugin for Sylius applications.",
1111
"license": "MIT",
1212
"require": {
13-
"php": "^8.0",
13+
"php": "^8.2",
1414
"ext-json": "*",
1515
"giggsey/libphonenumber-for-php": "^8.12",
1616
"payplug/payplug-php": "^3.1",
1717
"php-http/message-factory": "^1.1",
1818
"sylius/refund-plugin": "^2.0",
1919
"sylius/sylius": "^2.0",
20-
"symfony/asset": "^6.0|^7.0",
21-
"symfony/lock": "^6.0|^7.0",
22-
"symfony/validator": "^6.0|^7.0"
20+
"symfony/asset": "^6.4|| ^7.2",
21+
"symfony/lock": "^6.4|| ^7.2",
22+
"symfony/validator": "^6.4|| ^7.2"
2323
},
2424
"require-dev": {
2525
"behat/behat": "3.20.0",
@@ -34,8 +34,7 @@
3434
"friends-of-behat/suite-settings-extension": "1.1.0",
3535
"friends-of-behat/symfony-extension": "2.6.0",
3636
"friends-of-behat/variadic-extension": "1.6.0",
37-
"friendsoftwig/twigcs": "6.4.0",
38-
"j13k/yaml-lint": "1.1.6",
37+
"friendsoftwig/twigcs": "6.5.0",
3938
"lakion/mink-debug-extension": "2.0.0",
4039
"mockery/mockery": "1.6.12",
4140
"php-parallel-lint/php-parallel-lint": "1.4.0",
@@ -49,17 +48,23 @@
4948
"phpunit/phpunit": "9.6.22",
5049
"rector/rector": "2.0.4",
5150
"sylius-labs/coding-standard": "4.4.0",
52-
"symfony/browser-kit": "7.2.4",
53-
"symfony/debug-bundle": "^7.2.0",
54-
"symfony/dotenv": "7.2.0",
55-
"symfony/web-profiler-bundle": "7.2.4",
51+
"sylius/test-application": "^2.1.0@alpha",
52+
"symfony/apache-pack": "*",
53+
"symfony/browser-kit": "^6.4|| ^7.2",
54+
"symfony/debug-bundle": "^6.4|| ^7.2",
55+
"symfony/dotenv": "^6.4|| ^7.2",
56+
"symfony/web-profiler-bundle": "^6.4|| ^7.2",
5657
"webmozart/assert": "^1.8"
5758
},
5859
"prefer-stable": true,
5960
"autoload": {
6061
"psr-4": {
61-
"PayPlug\\SyliusPayPlugPlugin\\": "src/",
62-
"Tests\\PayPlug\\SyliusPayPlugPlugin\\": "tests/"
62+
"PayPlug\\SyliusPayPlugPlugin\\": "src/"
63+
}
64+
},
65+
"autoload-dev": {
66+
"psr-4": {
67+
"Tests\\PayPlug\\SyliusPayPlugPlugin\\": ["tests/", "tests/TestApplication/src/"]
6368
}
6469
},
6570
"config": {
@@ -70,6 +75,7 @@
7075
"phpro/grumphp": true,
7176
"phpstan/extension-installer": true,
7277
"symfony/flex": true,
78+
"symfony/runtime": true,
7379
"symfony/thanks": true
7480
}
7581
},
@@ -84,6 +90,26 @@
8490
"@phpmd",
8591
"@phpstan",
8692
"@phpunit"
93+
],
94+
"test-application:install": [
95+
"vendor/bin/console doctrine:database:drop --force --if-exists -n",
96+
"vendor/bin/console doctrine:database:create -n",
97+
"vendor/bin/console doctrine:migration:migrate -n",
98+
"vendor/bin/console sylius:payment:generate-key -n",
99+
"vendor/bin/console sylius:fixtures:load -n",
100+
"yarn --cwd vendor/sylius/test-application install",
101+
"yarn --cwd vendor/sylius/test-application build",
102+
"vendor/bin/console assets:install --symlink -n"
103+
],
104+
"test-application:front": [
105+
"yarn --cwd vendor/sylius/test-application install --force",
106+
"yarn --cwd vendor/sylius/test-application build"
87107
]
108+
},
109+
"extra": {
110+
"public-dir": "vendor/sylius/test-application/public",
111+
"symfony": {
112+
"require": "^6.4"
113+
}
88114
}
89115
}

install/Application/.gitignore

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

install/Application/config/packages/payplug.yaml

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

install/Application/config/packages/sylius_payplug.yaml

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

0 commit comments

Comments
 (0)