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

Behat tests (yet without JS) #6

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
47 changes: 26 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,35 @@ workflows:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
php_version:
- "8.0"
sylius_version:
- "1.11"
symfony_version:
- "5.4"
sylius_version: [ "1.11" ]
php_version: [ "8.0" ]
symfony_version: [ "5.4" ]
sylius1.11-php8.1+:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
sylius_version: [ "1.11" ]
php_version: [ "8.1", "8.2", "8.3" ]
symfony_version: [ "5.4" ]
sylius1.12-php8.0:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
php_version: [ "8.0" ]
sylius_version: [ "1.12" ]
php_version: [ "8.0" ]
symfony_version: [ "5.4", "6.0" ]
sylius1.11-php8.1+:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
sylius_version: [ "1.11" ]
symfony_version: [ "5.4" ]
php_version: [ "8.1", "8.2" ]
sylius1.12-php8.1+:
jobs:
- build:
name: php-<<matrix.php_version>>-sylius-<< matrix.sylius_version >>-symfony-<< matrix.symfony_version >>
matrix:
parameters:
sylius_version: [ "1.12" ]
php_version: [ "8.1", "8.2" ]
php_version: [ "8.1", "8.2", "8.3" ]
symfony_version: [ "5.4", "6.0", "6.1", "6.2", "6.3", "6.4" ]

jobs:
Expand Down Expand Up @@ -68,7 +65,7 @@ jobs:
- run: curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
- run: apt-get update
# netcat to get 'nc' command for waiting for database
- run: apt-get install -y nodejs yarn mariadb-client netcat
- run: apt-get install -y nodejs yarn mariadb-client netcat-traditional
- run: composer self-update

# Sylius & Symfony in current matrix versions
Expand All @@ -86,10 +83,17 @@ jobs:
- run: composer update --no-interaction --prefer-lowest --no-plugins
- run: yarn --cwd tests/Application install
- run: yarn --cwd tests/Application build
- run: (cd tests/Application && bin/console doctrine:database:create --if-not-exists --env=test -vvv)
- run: (cd tests/Application && bin/console doctrine:schema:update --force --env=test -vvv)
- run: (cd tests/Application && bin/console cache:clear --env=test -vvv)
- run: (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- run: (cd tests/Application && bin/console doctrine:database:create --if-not-exists --env=test -vvv)
- run: (cd tests/Application && bin/console doctrine:schema:update --force --complete --no-interaction --env=test -vvv)
- run: (cd tests/Application && bin/console doctrine:migrations:sync-metadata-storage --no-interaction --env=test -vvv)
- run:
name: Behat
environment:
APP_SUPPRESS_DEPRECATED_ERRORS: 1
# suppress deprecation errors like 'Function utf8_encode() is deprecated in vendor/egulias/email-validator/src/EmailLexer.php line 275' converted to fatal
command: APP_ENV=test php --define error_reporting=E_ALL^E_DEPRECATED bin/behat
- run: APP_ENV=test bin/phpstan.sh
- run: APP_ENV=test bin/ecs.sh --clear-cache
- run: APP_ENV=test bin/symfony-lint.sh
Expand All @@ -99,9 +103,10 @@ jobs:
- run: yarn --cwd tests/Application install
- run: yarn --cwd tests/Application build
- run: (cd tests/Application && bin/console doctrine:database:create --if-not-exists --env=test -vvv)
- run: (cd tests/Application && bin/console doctrine:schema:update --force --env=test -vvv)
- run: (cd tests/Application && bin/console doctrine:schema:update --force --complete --no-interaction --env=test -vvv)
- run: (cd tests/Application && bin/console cache:clear --env=test -vvv)
- run: (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- run: APP_ENV=test bin/behat
- run: APP_ENV=test bin/phpstan.sh
- run: APP_ENV=test bin/ecs.sh --clear-cache
- run: APP_ENV=test bin/symfony-lint.sh
22 changes: 22 additions & 0 deletions .docker/nginx/nginx-selfsigned.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDrTCCApWgAwIBAgIUKCa3obUEwPsaJOUUOkCRU/jmHqwwDQYJKoZIhvcNAQEL
BQAwZjELMAkGA1UEBhMCQ1oxEzARBgNVBAgMClNvbWUtU3RhdGUxDzANBgNVBAcM
BlByYWd1ZTERMA8GA1UECgwIM2Jycy5jb20xCzAJBgNVBAsMAklUMREwDwYDVQQD
DAgzYnJzLmNvbTAeFw0yNDAxMTEyMTE3NDhaFw0yNTAxMTAyMTE3NDhaMGYxCzAJ
BgNVBAYTAkNaMRMwEQYDVQQIDApTb21lLVN0YXRlMQ8wDQYDVQQHDAZQcmFndWUx
ETAPBgNVBAoMCDNicnMuY29tMQswCQYDVQQLDAJJVDERMA8GA1UEAwwIM2Jycy5j
b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8dCTNfrLtrpEyIR2f
XgcsQko4uEgP9fIdhe7sCz1cH2jx3KvLsa/IzElAtEqRXPOiVNt972zoi4+fw4A1
QBRWHg7IL1JkmfrbemhmkJHWv3+4h1FGvlyslNULSdtp/s00jSfCxqYd5fspu0hH
U5CcOvFg5Jh/YU54aBazIh42cJXxIBsv8TKkYMk1HlA6dZF/KMdzTy+Umu5sF9+r
X9sPB9m7xWbyyq5T1gKacE6CdCd0hy9IpdHpCCwY3cWvkBHBUM7FGvSl8OZyxRQX
nxkFXw6J0JP8Ns0g/q1nyvFTJbED8EVIyWP7MUKD+mocq/qGEoBmLidtZ89dcK1Z
UpzPAgMBAAGjUzBRMB0GA1UdDgQWBBSw6/8l/Q97IdML1lrNB7qY9MW/nTAfBgNV
HSMEGDAWgBSw6/8l/Q97IdML1lrNB7qY9MW/nTAPBgNVHRMBAf8EBTADAQH/MA0G
CSqGSIb3DQEBCwUAA4IBAQAXCwTa22HpSBJuEgbyKK1oBllEL6VCuDj6TvpUOMZC
TGMnUkMwBnS8/NzQ/qfVPix+x3qqDe4HzCrNYBO0LeaUp5yk93qAMgCXeJugGSIg
oAsBHvmVurCfmtVruLf/y8Df/IetKvcVmAAj0wt32gtB6TlpKkQPZdoLNvmEWIpm
2MC/OzTYGCPp6vry5JnIPZXOcuQjHgKhEPU7YeN5nIvvP27NfhXCXTubpag/7spp
7fq5hiSgZHsYAh9OIxdAfou1I8rbIenn8zElbOvc6bwU0drMykmAVMvpu55ctWGk
/cRl1D8UbcsDWUpiucnaMv3v64vA/9BlFx3mh1ORNDh/
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions .docker/nginx/nginx-selfsigned.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8dCTNfrLtrpEy
IR2fXgcsQko4uEgP9fIdhe7sCz1cH2jx3KvLsa/IzElAtEqRXPOiVNt972zoi4+f
w4A1QBRWHg7IL1JkmfrbemhmkJHWv3+4h1FGvlyslNULSdtp/s00jSfCxqYd5fsp
u0hHU5CcOvFg5Jh/YU54aBazIh42cJXxIBsv8TKkYMk1HlA6dZF/KMdzTy+Umu5s
F9+rX9sPB9m7xWbyyq5T1gKacE6CdCd0hy9IpdHpCCwY3cWvkBHBUM7FGvSl8OZy
xRQXnxkFXw6J0JP8Ns0g/q1nyvFTJbED8EVIyWP7MUKD+mocq/qGEoBmLidtZ89d
cK1ZUpzPAgMBAAECggEAAW+RQkuNbVyk2I5Ub2hyHFhBRY1HUsv3rDsce1a252fw
QhKvqLdHqAWiRZA2P8pRJinp0/Vx339hCCe+AMN1yAugvcONk26Qa84k6Ek40Ag/
KRGYy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Vttqy6jEXcCw8FoXdQUQg0b3nN+
fETGdtkVPcHxPpcV3Ws2600=
-----END PRIVATE KEY-----
12 changes: 11 additions & 1 deletion .docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ http {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

server {
server {
# Listen 80: This instructs the system to catch all HTTP traffic on Port 80
listen 80;
# Server_name _;: This will match any hostname
server_name _;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/nginx-selfsigned.crt;
ssl_certificate_key /etc/nginx/ssl/nginx-selfsigned.key;

server_name sylius_plugin_docker;

Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

#### Details

- Add support for Sylius 1.11|1.12, Symfony ^5.4|^6.0, PHP ^8.0
```diff
+ Add support for Sylius 1.11|1.12, Symfony ^5.4|^6.0, PHP ^8.0

- Drop support for Sylius <= 1.10 and consequentially for Symfony <= 5.3, <= PHP 7.4
```
- ⚠️ *BC break: interface \ThreeBRS\SyliusPaymentFeePlugin\Model\PaymentMethodWithFeeInterface enforces new methods `setCalculator`, `setCalculatorConfiguration` and `getTaxCategory`*
- 👎 Deprecated translation key `paymentFee_total` in favor of `payment_fee_total`
- 👎 Deprecated [Doctrine `@annotations`](https://www.doctrine-project.org/projects/doctrine-annotations/en/stable/index.html) in favor of [Doctrine `#[Atributtes]`](https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/attributes-reference.html)

## v1.0.0 (2021-11-10)

Expand Down
32 changes: 25 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
phpstan:
APP_ENV=test bin/phpstan.sh
bin/console cache:warmup
bin/phpstan.sh

ecs:
APP_ENV=test bin/ecs.sh
bin/ecs.sh

behat-no-js:
bin/behat --colors --strict --no-interaction -vvv -f progress --tags="~@javascript"

behat: behat-no-js

install:
composer install --no-interaction --no-scripts

backend-bare:
bin/console doctrine:database:create --if-not-exists --no-interaction
bin/console doctrine:migrations:sync-metadata-storage --no-interaction
bin/console doctrine:schema:update --force --complete --no-interaction

backend:
APP_ENV=test tests/Application/bin/console sylius:install --no-interaction
APP_ENV=test tests/Application/bin/console doctrine:schema:update --force --complete --no-interaction
APP_ENV=test tests/Application/bin/console sylius:fixtures:load default --no-interaction
bin/console doctrine:database:create --if-not-exists --no-interaction
bin/console sylius:install --no-interaction # create schema and fixtures
# requires update of database schema due to plugin entities
bin/console doctrine:migrations:sync-metadata-storage --no-interaction
bin/console doctrine:schema:update --force --complete --no-interaction
bin/console sylius:fixtures:load default --no-interaction

frontend:
(cd tests/Application && yarn install --pure-lockfile)
(cd tests/Application && GULP_ENV=prod yarn build)

lint:
APP_ENV=test bin/symfony-lint.sh
bin/symfony-lint.sh

init: install backend frontend

ci: init phpstan ecs lint
init-integration: install backend-bare frontend

integration: init-integration behat

static: install phpstan ecs lint

ci: static integration
77 changes: 41 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,53 +49,53 @@ For guide how to use your own entity see [Sylius docs - Customizing Models](http

1. Include `@ThreeBRSSyliusPaymentFeePlugin/Admin/_form.html.twig` into `@SyliusAdmin/PaymentMethod/_form.html.twig`.

```twig
{# ... #}

{% include '@ThreeBRSSyliusPaymentFeePlugin/Admin/_form.html.twig' %}
```
```twig
{# ... #}
{% include '@ThreeBRSSyliusPaymentFeePlugin/Admin/_form.html.twig' %}
```

1. Include `@ThreeBRSSyliusPaymentFeePlugin/Admin/_order_show.html.twig` into `@AdminBundle/Order/Show/Summary/_totals.html.twig`.

```twig
{# ... #}

{% include '@ThreeBRSSyliusPaymentFeePlugin/Admin/_order_show.html.twig' %}
```
```twig
{# ... #}
{% include '@ThreeBRSSyliusPaymentFeePlugin/Admin/_order_show.html.twig' %}
```

### Shop

1. Include `@ThreeBRSSyliusPaymentFeePlugin/Shop/Checkout/SelectPayment/_choice.html.twig` into `@ShopBundle/Checkout/SelectPayment/_choice.html.twig`.

```twig
{# ... #}

{% include '@ThreeBRSSyliusPaymentFeePlugin/Shop/Checkout/SelectPayment/_choice.html.twig' %}
```
```twig
{# ... #}
{% include '@ThreeBRSSyliusPaymentFeePlugin/Shop/Checkout/SelectPayment/_choice.html.twig' %}
```

1. Add variable fee `{% set fee = form.method.vars.payment_costs[choice_form.vars.value] %}` into `@ShopBundle/Checkout/SelectPayment/_payment.html.twig` into `foreach`.

```twig
{# ... #}

{% for key, choice_form in form.method %}
{% set fee = form.method.vars.payment_costs[choice_form.vars.value] %}
{% include '@SyliusShop/Checkout/SelectPayment/_choice.html.twig' with {'form': choice_form, 'method': form.method.vars.choices[key].data} %}
{% else %}
{% include '@SyliusShop/Checkout/SelectPayment/_unavailable.html.twig' %}
{% endfor %}
```
```twig
{# ... #}
{% for key, choice_form in form.method %}
{% set fee = form.method.vars.payment_costs[choice_form.vars.value] %}
{% include '@SyliusShop/Checkout/SelectPayment/_choice.html.twig' with {'form': choice_form, 'method': form.method.vars.choices[key].data} %}
{% else %}
{% include '@SyliusShop/Checkout/SelectPayment/_unavailable.html.twig' %}
{% endfor %}
```

1. Include `@ThreeBRSSyliusPaymentFeePlugin/Shop/Common/Order/Table/_payment.html.twig` into `@ShopBundle/Common/Order/Table/_totals.html.twig`.

```twig
{# ... #}

<tr>
{% include '@SyliusShop/Common/Order/Table/_shipping.html.twig' with {'order': order} %}
</tr>
{% include '@ThreeBRSSyliusPaymentFeePlugin/Shop/Common/Order/Table/_payment.html.twig' with {'order': order} %}
```
```twig
{# ... #}
<tr>
{% include '@SyliusShop/Common/Order/Table/_shipping.html.twig' with {'order': order} %}
</tr>
{% include '@ThreeBRSSyliusPaymentFeePlugin/Shop/Common/Order/Table/_payment.html.twig' with {'order': order} %}
```

1. Create and run doctrine database migrations
```bash
Expand Down Expand Up @@ -130,12 +130,17 @@ bin/ecs.sh
vendor/bin/phpspec run
```

#### Behat Debugging
- use `-vvv` for verbose output `bin/behat -vvv`
- see `etc/build/*.html` for output detail
- check `tests/Application/var/log/test.log` for errors

### Opening Sylius with your plugin

1. Install symfony CLI command: https://symfony.com/download
- hint: for Docker (with Ubuntu) use _Debian/Ubuntu — APT based
Linux_ installation steps as `root` user and without `sudo` command
- you may need to install `curl` first ```apt-get update && apt-get install curl --yes```
- hint: for Docker (with Ubuntu) use _Debian/Ubuntu — APT based
Linux_ installation steps as `root` user and without `sudo` command
- you may need to install `curl` first ```apt-get update && apt-get install curl --yes```
2. Run app

```bash
Expand Down
56 changes: 56 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml

default:
extensions:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~

FriendsOfBehat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true

Behat\MinkExtension:
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
sessions:
symfony:
symfony: ~
chrome_headless:
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:
unexpectedAlertBehaviour: accept
firefox:
selenium2:
browser: firefox
show_auto: false

FriendsOfBehat\SymfonyExtension:
bootstrap: tests/Application/config/bootstrap.php
kernel:
class: Tests\ThreeBRS\SyliusPaymentFeePlugin\Kernel
environment: test

FriendsOfBehat\VariadicExtension: ~

FriendsOfBehat\SuiteSettingsExtension:
paths:
- "features"
Loading