diff --git a/.gitignore b/.gitignore
index 664f929..07229a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@
!/etc/build/.gitignore
/tests/Application/yarn.lock
+
+/behat.yml
+/phpspec.yml
diff --git a/.travis.yml b/.travis.yml
index 011f444..32cfc90 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,7 @@ cache:
env:
global:
+ - APP_ENV=test
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build
matrix:
@@ -27,13 +28,9 @@ before_install:
- mkdir -p "${SYLIUS_CACHE_DIR}"
- mkdir -p tests/Application/web/media/image
- - cp tests/Application/.env.test.dist tests/Application/.env.test
- - set -a && source tests/Application/.env.test && set +a
-
install:
- composer require "symfony/browser-kit:${SYMFONY_VERSION}" --no-interaction --no-update
- composer require "symfony/debug-bundle:${SYMFONY_VERSION}" --no-interaction --no-update
- - composer require "symfony/dotenv:${SYMFONY_VERSION}" --no-interaction --no-update
- composer require "symfony/intl:${SYMFONY_VERSION}" --no-interaction --no-update
- composer require "symfony/web-profiler-bundle:${SYMFONY_VERSION}" --no-interaction --no-update
- composer require "symfony/web-server-bundle:${SYMFONY_VERSION}" --no-interaction --no-update
@@ -41,10 +38,10 @@ install:
- (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 public --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
@@ -74,7 +71,7 @@ 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 public --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
diff --git a/behat.yml.dist b/behat.yml.dist
index d6bf7f9..05d3376 100644
--- a/behat.yml.dist
+++ b/behat.yml.dist
@@ -1,24 +1,47 @@
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
+ Lakion\Behat\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: "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"
+ firefox:
+ selenium2:
+ browser: firefox
+ show_auto: false
FriendsOfBehat\SymfonyExtension:
- env_file: tests/Application/.env.test
+ bootstrap: tests/Application/config/bootstrap.php
kernel:
- env: test
- debug: true
class: Tests\Acme\SyliusExamplePlugin\Application\Kernel
- path: tests/Application/Kernel.php
- bootstrap: ~
- Lakion\Behat\MinkDebugExtension:
- directory: etc/build
- clean_start: false
- screenshot: true
+ FriendsOfBehat\VariadicExtension: ~
+
+ FriendsOfBehat\SuiteSettingsExtension:
+ paths:
+ - "features"
diff --git a/composer.json b/composer.json
index adb1057..8d17aeb 100644
--- a/composer.json
+++ b/composer.json
@@ -15,11 +15,9 @@
"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/page-object-extension": "^0.2.1",
- "friends-of-behat/service-container-extension": "^1.0",
- "friends-of-behat/symfony-extension": "^1.2.1",
+ "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": "^5.0",
@@ -32,7 +30,7 @@
"sylius-labs/coding-standard": "^2.0",
"symfony/browser-kit": "^3.4|^4.1",
"symfony/debug-bundle": "^3.4|^4.1",
- "symfony/dotenv": "^3.4|^4.1",
+ "symfony/dotenv": "^4.2",
"symfony/intl": "^3.4|^4.1",
"symfony/web-profiler-bundle": "^3.4|^4.1",
"symfony/web-server-bundle": "^3.4|^4.1"
@@ -51,6 +49,9 @@
"Tests\\Acme\\SyliusExamplePlugin\\": "tests/"
}
},
+ "autoload-dev": {
+ "classmap": ["tests/Application/Kernel.php"]
+ },
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 8113386..3762a13 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -4,11 +4,13 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.6/phpunit.xsd"
backupGlobals="false"
colors="true"
- bootstrap="vendor/autoload.php">
+ bootstrap="tests/Application/config/bootstrap.php">
tests
+
+
diff --git a/tests/Application/.env.dist b/tests/Application/.env
similarity index 100%
rename from tests/Application/.env.dist
rename to tests/Application/.env
diff --git a/tests/Application/.env.prod.dist b/tests/Application/.env.prod.dist
deleted file mode 100644
index 2e67200..0000000
--- a/tests/Application/.env.prod.dist
+++ /dev/null
@@ -1,23 +0,0 @@
-# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
-# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
-# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
-
-###> symfony/framework-bundle ###
-APP_ENV=prod
-APP_DEBUG=0
-APP_SECRET=EDITME
-###< symfony/framework-bundle ###
-
-###> doctrine/doctrine-bundle ###
-# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
-# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
-# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
-DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
-###< doctrine/doctrine-bundle ###
-
-###> symfony/swiftmailer-bundle ###
-# For Gmail as a transport, use: "gmail://username:password@localhost"
-# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
-# Delivery is disabled by default via "null://localhost"
-MAILER_URL=smtp://localhost
-###< symfony/swiftmailer-bundle ###
diff --git a/tests/Application/.env.test b/tests/Application/.env.test
new file mode 100644
index 0000000..c0ee239
--- /dev/null
+++ b/tests/Application/.env.test
@@ -0,0 +1,3 @@
+APP_SECRET='ch4mb3r0f5ecr3ts'
+
+KERNEL_CLASS='Tests\Acme\SyliusExamplePlugin\Application\Kernel'
diff --git a/tests/Application/.env.test.dist b/tests/Application/.env.test.dist
deleted file mode 100644
index 7ef5bb5..0000000
--- a/tests/Application/.env.test.dist
+++ /dev/null
@@ -1,23 +0,0 @@
-# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
-# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
-# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
-
-###> symfony/framework-bundle ###
-APP_ENV=test
-APP_DEBUG=1
-APP_SECRET=EDITME
-###< symfony/framework-bundle ###
-
-###> doctrine/doctrine-bundle ###
-# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
-# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
-# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
-DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
-###< doctrine/doctrine-bundle ###
-
-###> symfony/swiftmailer-bundle ###
-# For Gmail as a transport, use: "gmail://username:password@localhost"
-# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
-# Delivery is disabled by default via "null://localhost"
-MAILER_URL=null://localhost
-###< symfony/swiftmailer-bundle ###
diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore
index 81107f1..8ad1225 100644
--- a/tests/Application/.gitignore
+++ b/tests/Application/.gitignore
@@ -1,8 +1,4 @@
-/var/*
-!/var/.gitignore
-
/public/assets
-/public/bundles
/public/css
/public/js
/public/media/*
@@ -10,11 +6,17 @@
/public/media/image/*
!/public/media/image/.gitignore
-/vendor
/node_modules
-/.env
-/.env.prod
-/.env.staging
-/.env.test
-/.env.test_cached
+###> symfony/framework-bundle ###
+/.env.*.local
+/.env.local
+/.env.local.php
+/public/bundles
+/var/
+/vendor/
+###< symfony/framework-bundle ###
+
+###> symfony/web-server-bundle ###
+/.web-server-pid
+###< symfony/web-server-bundle ###
diff --git a/tests/Application/bin/console b/tests/Application/bin/console
index 2a2ef58..bf889e9 100755
--- a/tests/Application/bin/console
+++ b/tests/Application/bin/console
@@ -1,36 +1,31 @@
#!/usr/bin/env php
getParameterOption(['--env', '-e'], null, true)) {
+ putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
+}
- $envFile = file_exists(__DIR__.'/../.env') ? __DIR__.'/../.env' : __DIR__.'/../.env.dist';
- (new Dotenv())->load($envFile);
+if ($input->hasParameterOption('--no-debug', true)) {
+ putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
-$input = new ArgvInput();
-$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
-$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
+require dirname(__DIR__).'/config/bootstrap.php';
-if ($debug) {
+if ($_SERVER['APP_DEBUG']) {
umask(0000);
if (class_exists(Debug::class)) {
@@ -38,6 +33,6 @@ if ($debug) {
}
}
-$kernel = new Kernel($env, $debug);
+$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php
new file mode 100644
index 0000000..6bb0207
--- /dev/null
+++ b/tests/Application/config/bootstrap.php
@@ -0,0 +1,21 @@
+=1.2)
+if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
+ $_SERVER += $env;
+ $_ENV += $env;
+} elseif (!class_exists(Dotenv::class)) {
+ throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
+} else {
+ // load all the .env files
+ (new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
+}
+
+$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
+$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
+$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php
index 2c7359b..689934c 100644
--- a/tests/Application/config/bundles.php
+++ b/tests/Application/config/bundles.php
@@ -56,4 +56,5 @@
Acme\SyliusExamplePlugin\AcmeSyliusExamplePlugin::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
+ FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
];
diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml
new file mode 100644
index 0000000..d9b02e3
--- /dev/null
+++ b/tests/Application/config/services_test.yaml
@@ -0,0 +1,3 @@
+imports:
+ - { resource: "../../Behat/Resources/services.xml" }
+ - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" }
diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php
index 879052d..2f8f1b1 100644
--- a/tests/Application/public/index.php
+++ b/tests/Application/public/index.php
@@ -1,42 +1,26 @@
load($envFile);
-}
-$env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'dev';
-$debug = (bool) ($_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? ('prod' !== $env));
+require dirname(__DIR__).'/config/bootstrap.php';
-if ($debug) {
+if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
-if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
+if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
-if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
- Request::setTrustedHosts(explode(',', $trustedHosts));
+if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
+ Request::setTrustedHosts([$trustedHosts]);
}
-$kernel = new Kernel($env, $debug);
+$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
diff --git a/tests/Behat/Resources/services.xml b/tests/Behat/Resources/services.xml
index 0a688c2..8c823e9 100644
--- a/tests/Behat/Resources/services.xml
+++ b/tests/Behat/Resources/services.xml
@@ -2,12 +2,12 @@
+
-
diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml
index 914463a..6cfe415 100644
--- a/tests/Behat/Resources/suites.yml
+++ b/tests/Behat/Resources/suites.yml
@@ -3,7 +3,7 @@
default:
suites:
greeting_customer:
- contexts_services:
+ contexts:
- acme_sylius_example.context.ui.shop.welcome
filters: