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

pr/behat test #6

Open
wants to merge 1 commit 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
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/SyliusPaymentFeePlugin.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 13 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ dist: trusty
sudo: false

php:
- 7.2
- '7.2'
- '7.3'

cache:
yarn: true
Expand All @@ -15,27 +16,24 @@ cache:

env:
global:
- APP_ENV=test
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build
matrix:
- SYMFONY_VERSION="3.4.*"
- SYMFONY_VERSION="4.1.*"

before_install:
- phpenv config-rm xdebug.ini
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- mkdir -p "${SYLIUS_CACHE_DIR}"

install:
- composer require "symfony/symfony:${SYMFONY_VERSION}" --no-interaction --no-update
- composer install --no-interaction --prefer-dist
- (cd tests/Application && yarn install)

before_script:
- (cd tests/Application && bin/console doctrine:database:create --env=test -vvv)
- (cd tests/Application && bin/console doctrine:schema:create --env=test -vvv)
- (cd tests/Application && bin/console assets:install web --env=test -vvv)
- (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- (cd tests/Application && bin/console doctrine:database:create -vvv)
- (cd tests/Application && bin/console doctrine:schema:create -vvv)
- (cd tests/Application && bin/console assets:install public -vvv)
- (cd tests/Application && bin/console cache:warmup -vvv)
- (cd tests/Application && yarn build)

# Configure display
Expand Down Expand Up @@ -65,15 +63,15 @@ before_script:
- java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar > /dev/null 2>&1 &

# Run webserver
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web --env=test --quiet > /dev/null 2>&1 &)
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 --quiet > /dev/null 2>&1 &)

script:
- composer validate --strict
- bin/phpstan.phar analyse -c phpstan.neon -l max src/
- composer validate
- vendor/bin/phpstan analyse -c phpstan.neon -l max src/

- bin/phpunit
- bin/phpspec run
- bin/behat --strict -vvv --no-interaction || bin/behat --strict -vvv --no-interaction --rerun
- vendor/bin/phpunit
- vendor/bin/phpspec run
- vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun

after_failure:
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"
51 changes: 38 additions & 13 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
imports:
- vendor/sylius/sylius/behat.yml.dist
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml

default:
extensions:
FriendsOfBehat\ContextServiceExtension:
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml
- tests/Behat/Resources/services.xml

FriendsOfBehat\SymfonyExtension:
kernel:
class: \App\Kernel
path: tests/Application/src/Kernel.php
bootstrap: vendor/autoload.php

Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true

Behat\MinkExtension:
base_url: "http://nginx"
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
base_url: "http://localhost:8080/"
default_session: symfony
javascript_session: chrome
sessions:
symfony:
symfony: ~
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\MangoSylius\PaymentFeePlugin\Application\Kernel

FriendsOfBehat\VariadicExtension: ~

FriendsOfBehat\SuiteSettingsExtension:
paths:
- "features"
11 changes: 11 additions & 0 deletions bin/behat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# project root
cd "$(dirname "$DIR")"

set -x

vendor/bin/behat features
3 changes: 1 addition & 2 deletions bin/ecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ cd "$(dirname "$DIR")"

set -x

rm -rf tests/Application/var/cache/
vendor/bin/ecs check src tests "$@"
vendor/bin/ecs check src "$@"
2 changes: 1 addition & 1 deletion bin/phpstan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ cd "$(dirname "$DIR")"
set -x
vendor/bin/phpstan analyse \
--level 7 \
--memory-limit 1G \
--memory-limit 2G \
--configuration phpstan.neon \
src tests
93 changes: 50 additions & 43 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
{
"name": "mangoweb-sylius/sylius-payment-fee-plugin",
"type": "sylius-plugin",
"description": "Payment fee plugin for Sylius.",
"license": "proprietary",
"require": {
"php": "^7.1",
"sylius/sylius": "^1.2.5",
"symfony/symfony": "^4.1",
"symfony/framework-bundle": "^4.1"
},
"require-dev": {
"behat/behat": "^3.4",
"behat/mink": "^1.7@dev",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/context-service-extension": "^1.2",
"friends-of-behat/cross-container-extension": "^1.1",
"friends-of-behat/service-container-extension": "^1.0",
"friends-of-behat/symfony-extension": "^1.2.1",
"friends-of-behat/variadic-extension": "^1.1",
"lakion/mink-debug-extension": "^1.2.3",
"phpstan/phpstan-doctrine": "^0.10",
"phpstan/phpstan-shim": "^0.10",
"phpstan/phpstan-symfony": "^0.10",
"phpstan/phpstan-webmozart-assert": "^0.10",
"phpunit/phpunit": "^6.5",
"sylius-labs/coding-standard": "^2.0",
"se/selenium-server-standalone": "^3.12",
"symfony/templating": "^4.1"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"MangoSylius\\PaymentFeePlugin\\": "src/",
"Tests\\MangoSylius\\PaymentFeePlugin\\": "tests/"
}
},
"autoload-dev": {
"psr-4": {
"App\\": "tests/Application/src/"
}
}
"name": "mangoweb-sylius/sylius-payment-fee-plugin",
"type": "sylius-plugin",
"keywords": ["sylius", "sylius-plugin"],
"description": "Payment fee plugin for Sylius.",
"license": "MIT",
"require": {
"php": "^7.2",

"sylius/sylius": "^1.6"
},
"require-dev": {
"behat/behat": "^3.4",
"behat/mink": "^1.7@dev",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.0",
"friends-of-behat/variadic-extension": "^1.1",
"lakion/mink-debug-extension": "^1.2.3",
"phpspec/phpspec": "^6.1",
"phpstan/phpstan-doctrine": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-webmozart-assert": "^0.11",
"phpunit/phpunit": "^8.0",
"sensiolabs/security-checker": "^5.0",
"sylius-labs/coding-standard": "^3.0",
"symfony/browser-kit": "^3.4|^4.3",
"symfony/debug-bundle": "^3.4|^4.3",
"symfony/dotenv": "^4.3",
"symfony/intl": "^3.4|^4.3",
"symfony/web-profiler-bundle": "^3.4|^4.3",
"symfony/web-server-bundle": "^3.4|^4.3"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"MangoSylius\\PaymentFeePlugin\\": "src/",
"Tests\\MangoSylius\\PaymentFeePlugin\\": "tests/"
}
},
"autoload-dev": {
"classmap": ["tests/Application/Kernel.php"]
},
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
}
}
}
4 changes: 0 additions & 4 deletions easy-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
imports:
- { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' }

parameters:
indentation: tab

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@set_payment_method_extra_fee
Feature: Set payment method extra fee
In order to add extra fee for a certain payment method
As an Administrator
I want to be able to define a extra fee amount for a payment method

Background:
Given the store operates on a single channel in "United States"
And the store has zones "NorthAmerica", "SouthAmerica" and "Europe"
And the store has a payment method "Offline" with a code "offline"
And I am logged in as an administrator

@ui
Scenario: Being able to define a fee amount for the payment method
Given I want to modify the "Offline" payment method
When I save my changes
And I add an extra fee of '30'$
And I save my changes
Then I should be notified that it has been successfully edited
And this payment method have an extra fee of '30'$
4 changes: 4 additions & 0 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
suites:
main:
namespace: MangoSylius\PaymentFeePlugin
psr4_prefix: MangoSylius\PaymentFeePlugin
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon


parameters:
symfony:
container_xml_path: tests/Application/var/cache/dev/srcDevDebugProjectContainer.xml
container_xml_path: tests/Application/var/cache/test/testContainer.xml

excludes_analyse:
# Too slow
- 'src/DependencyInjection/Configuration.php'

# Test dependencies
- '*/tests/Application/var/*'

- 'src/Migrations/'
- 'tests/'
12 changes: 7 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.6/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.0/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php">
bootstrap="tests/Application/config/bootstrap.php">
<testsuites>
<testsuite name="MangoSyliusPaymentFeePlugin Test Suite">
<testsuite name="AcmeSyliusExamplePlugin Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<php>
<server name="KERNEL_CLASS_PATH" value="/tests/Application/src/Kernel.php" />
<server name="KERNEL_CLASS_PATH" value="/tests/Application/AppKernel.php" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />

<env name="APP_ENV" value="test"/>
<env name="SHELL_VERBOSITY" value="-1" />
</php>
</phpunit>
Loading