Skip to content

Commit

Permalink
Merge pull request #1836 from meyerbaptiste/speed_up_travis
Browse files Browse the repository at this point in the history
Speed-up Travis
  • Loading branch information
dunglas committed Apr 9, 2018
2 parents a437254 + df2db6b commit 0b3e937
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -17,12 +17,12 @@ matrix:
- php: '7.0'
- php: '7.1'
- php: '7.2'
- php: '7.2'
env: coverage=1
- php: '7.2'
env: lint=1
- php: '7.2'
env: deps=low
- php: '7.2'
env: coverage=1
- php: '7.2'
env: SYMFONY_DEPRECATIONS_HELPER=0
- php: '7.2'
Expand Down Expand Up @@ -75,9 +75,9 @@ install:

script:
- if [[ $coverage = 1 ]]; then
phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov;
APP_ENV=test_phpunit phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov;
elif [[ $lint != 1 ]]; then
vendor/bin/phpunit;
APP_ENV=test_phpunit vendor/bin/phpunit;
fi
- if [[ $coverage = 1 ]]; then
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature'); do
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Expand Up @@ -31,7 +31,7 @@ default:
extensions:
'Behat\Symfony2Extension':
kernel:
env: '%env(APP_ENV)%'
env: 'test'
debug: 'true'
path: 'tests/Fixtures/app/AppKernel.php'
bootstrap: 'tests/Fixtures/app/bootstrap.php'
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Expand Up @@ -12,6 +12,7 @@
<ini name="memory_limit" value="-1" />
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="APP_ENV" value="test_phpunit" />
<server name="LEGACY" value="0" />
</php>

Expand Down
16 changes: 9 additions & 7 deletions tests/Fixtures/app/AppKernel.php
Expand Up @@ -38,6 +38,14 @@ class AppKernel extends Kernel
{
use MicroKernelTrait;

public function __construct(string $environment, bool $debug)
{
parent::__construct($environment, $debug);

// patch for behat/symfony2-extension not supporting %env(APP_ENV)%
$this->environment = $_SERVER['APP_ENV'] ?? $environment;
}

public function registerBundles(): array
{
$bundles = [
Expand Down Expand Up @@ -69,15 +77,9 @@ protected function configureRoutes(RouteCollectionBuilder $routes)

protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
{
$environment = $this->getEnvironment();
$c->setParameter('kernel.project_dir', __DIR__);

// patch for behat not supporting %env(APP_ENV)% in older versions
if (($appEnv = $_SERVER['APP_ENV'] ?? 'test') && $appEnv !== $environment) {
$environment = $appEnv;
}

$loader->load("{$this->getRootDir()}/config/config_{$environment}.yml");
$loader->load("{$this->getRootDir()}/config/config_{$this->getEnvironment()}.yml");

$securityConfig = [
'encoders' => [
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/app/config/config_test_phpunit.yml
@@ -0,0 +1,2 @@
imports:
- { resource: config_test.yml }

0 comments on commit 0b3e937

Please sign in to comment.