From b96b8c8fc8f529ce53090655b419694472ca4f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Zl=C3=A1mal?= Date: Mon, 6 Feb 2017 14:39:41 +0100 Subject: [PATCH] Add '--bootstrap' option This option will propagate bootstrap file path into BOOTSTRAP environment variable. --- .travis.yml | 2 +- src/Runner.php | 7 +++++++ tests/Runner/Bootstrap.phpt | 5 +++++ tests/Traits/LatteExceptionTest.phpt | 2 +- tests/Traits/MultipleTraits.phpt | 2 +- tests/Traits/PresenterModuleTest.phpt | 2 +- tests/Traits/TCompiledContainerTest.phpt | 2 +- tests/Traits/TComponentTest.phpt | 2 +- tests/Traits/TDoctrineTest.phpt | 2 +- tests/Traits/TNetteDatabaseTest.phpt | 2 +- tests/Traits/TPresenterTest.phpt | 2 +- 11 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 256186f..213c11f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_script: - "sh -c \"if [ '$DB' = 'pgsql' ]; then cp tests/_helpers/pgsql.neon tests/tests.local.neon; fi\"" script: - - src/run-tests + - src/run-tests --bootstrap tests/bootstrap.php - php tests/Scaffold/GenerateStructure.php - cp tests/FakeBootstrapForScaffold.php tests/_temp/scaffold/bootstrap.php - php tests/_temp/scaffold/PresenterPresenter.phpt diff --git a/src/Runner.php b/src/Runner.php index d4b9082..c9c84af 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -105,6 +105,13 @@ public function prepareArguments(array $args, $testsDir) } } + //Propagate bootstrap file into ENV + if (isset($parameters['--bootstrap'])) { + $bootstrapFile = realpath($parameters['--bootstrap']); + putenv('BOOTSTRAP=' . $bootstrapFile); + unset($parameters['--bootstrap']); + } + if ($pathToTests === NULL) { $pathToTests = $testsDir; } diff --git a/tests/Runner/Bootstrap.phpt b/tests/Runner/Bootstrap.phpt index 0c6affe..eabefae 100644 --- a/tests/Runner/Bootstrap.phpt +++ b/tests/Runner/Bootstrap.phpt @@ -25,6 +25,11 @@ class Bootstrap extends \Tester\TestCase Assert::same('Europe/Prague', date_default_timezone_get()); } + public function testBootstrapEnvVariable() + { + Assert::same(realpath(__DIR__ . '/../bootstrap.php'), getenv('BOOTSTRAP')); + } + public function testServerSuperglobalVariable() { Assert::same('Awesome Browser', $_SERVER['HTTP_USER_AGENT']); diff --git a/tests/Traits/LatteExceptionTest.phpt b/tests/Traits/LatteExceptionTest.phpt index 0084ffd..d9c0d94 100644 --- a/tests/Traits/LatteExceptionTest.phpt +++ b/tests/Traits/LatteExceptionTest.phpt @@ -2,7 +2,7 @@ namespace Tests\Traits; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/MultipleTraits.phpt b/tests/Traits/MultipleTraits.phpt index 5c1f427..8423014 100644 --- a/tests/Traits/MultipleTraits.phpt +++ b/tests/Traits/MultipleTraits.phpt @@ -2,7 +2,7 @@ namespace Tests\Traits; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/PresenterModuleTest.phpt b/tests/Traits/PresenterModuleTest.phpt index 6035626..c3f05fa 100644 --- a/tests/Traits/PresenterModuleTest.phpt +++ b/tests/Traits/PresenterModuleTest.phpt @@ -2,7 +2,7 @@ namespace Tests\Traits; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/TCompiledContainerTest.phpt b/tests/Traits/TCompiledContainerTest.phpt index 3198e3b..8b9f0d6 100644 --- a/tests/Traits/TCompiledContainerTest.phpt +++ b/tests/Traits/TCompiledContainerTest.phpt @@ -4,7 +4,7 @@ namespace Tests\Traits; use Tester\Assert; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/TComponentTest.phpt b/tests/Traits/TComponentTest.phpt index 6402f94..8717fcf 100644 --- a/tests/Traits/TComponentTest.phpt +++ b/tests/Traits/TComponentTest.phpt @@ -4,7 +4,7 @@ namespace Tests\Traits; use Tester\Assert; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/TDoctrineTest.phpt b/tests/Traits/TDoctrineTest.phpt index d69d9c4..79cd896 100644 --- a/tests/Traits/TDoctrineTest.phpt +++ b/tests/Traits/TDoctrineTest.phpt @@ -5,7 +5,7 @@ namespace Tests\Traits; use Doctrine\DBAL\Platforms\MySqlPlatform; use Tester\Assert; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/TNetteDatabaseTest.phpt b/tests/Traits/TNetteDatabaseTest.phpt index 13c1d50..b5c2b99 100644 --- a/tests/Traits/TNetteDatabaseTest.phpt +++ b/tests/Traits/TNetteDatabaseTest.phpt @@ -5,7 +5,7 @@ namespace Tests\Traits; use Nette\Database\Drivers\MySqlDriver; use Tester\Assert; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase diff --git a/tests/Traits/TPresenterTest.phpt b/tests/Traits/TPresenterTest.phpt index 6dec311..9caf885 100644 --- a/tests/Traits/TPresenterTest.phpt +++ b/tests/Traits/TPresenterTest.phpt @@ -5,7 +5,7 @@ namespace Tests\Traits; use Tester\Assert; use Tester\Dumper; -require __DIR__ . '/../bootstrap.php'; +require getenv('BOOTSTRAP'); /** * @testCase