Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Add '--bootstrap' option
Browse files Browse the repository at this point in the history
This option will propagate bootstrap file path into BOOTSTRAP environment variable.
  • Loading branch information
mrtnzlml committed Feb 6, 2017
1 parent 7e0dcfa commit b96b8c8
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Runner/Bootstrap.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/LatteExceptionTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Traits;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/MultipleTraits.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Traits;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/PresenterModuleTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Traits;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/TCompiledContainerTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Tests\Traits;

use Tester\Assert;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/TComponentTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Tests\Traits;

use Tester\Assert;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/TDoctrineTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Tests\Traits;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Tester\Assert;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/TNetteDatabaseTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Tests\Traits;
use Nette\Database\Drivers\MySqlDriver;
use Tester\Assert;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/TPresenterTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Tests\Traits;
use Tester\Assert;
use Tester\Dumper;

require __DIR__ . '/../bootstrap.php';
require getenv('BOOTSTRAP');

/**
* @testCase
Expand Down

0 comments on commit b96b8c8

Please sign in to comment.