Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace NepadaTests; | ||
|
||
use Tester; | ||
|
||
abstract class TestCase extends Tester\TestCase | ||
{ | ||
|
||
public function run(): void | ||
{ | ||
if ($_ENV['IS_PHPSTAN'] ?? false) { | ||
return; | ||
} | ||
|
||
parent::run(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
// The Nette Tester command-line runner can be | ||
// invoked through the command: ../vendor/bin/tester . | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
if (@!include __DIR__ . '/../vendor/autoload.php') { | ||
echo 'Install Nette Tester using `composer install`'; | ||
exit(1); | ||
// detect PHPStan | ||
if (!isset($_ENV['IS_PHPSTAN'])) { | ||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | ||
$_ENV['IS_PHPSTAN'] = (bool) preg_match('~[/\\\\]phpstan(?:\.phar)?$~', end($trace)['file'] ?? ''); | ||
} | ||
|
||
|
||
// configure environment | ||
Tester\Environment::setup(); | ||
date_default_timezone_set('Europe/Prague'); | ||
if (!$_ENV['IS_PHPSTAN']) { | ||
Tester\Environment::setup(); | ||
date_default_timezone_set('Europe/Prague'); | ||
} | ||
|
||
|
||
// create temporary directory | ||
define('TEMP_DIR', __DIR__ . '/temp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid())); | ||
@mkdir(dirname(TEMP_DIR)); // @ - directory may already exist | ||
Tester\Helpers::purge(TEMP_DIR); | ||
ini_set('session.save_path', TEMP_DIR); | ||
|
||
|
||
$_SERVER = array_intersect_key( | ||
$_SERVER, | ||
array_flip(['PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv']) | ||
); | ||
$_SERVER['REQUEST_TIME'] = 1234567890; | ||
$_ENV = $_GET = $_POST = []; | ||
if (!$_ENV['IS_PHPSTAN']) { | ||
@mkdir(dirname(TEMP_DIR)); // @ - directory may already exist | ||
Tester\Helpers::purge(TEMP_DIR); | ||
ini_set('session.save_path', TEMP_DIR); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
includes: | ||
- phar://phpstan.phar/vendor/phpstan/phpstan-nette/extension.neon | ||
- phar://phpstan.phar/vendor/phpstan/phpstan-nette/rules.neon | ||
- phar://phpstan.phar/vendor/phpstan/phpstan-strict-rules/rules.neon | ||
|
||
parameters: | ||
fileExtensions: | ||
- php | ||
- phpt | ||
|
||
autoload_directories: | ||
- %currentWorkingDirectory%/tests | ||
|
||
excludes_analyse: | ||
- %currentWorkingDirectory%/tests/bootstrap.php | ||
- %currentWorkingDirectory%/tests/temp/* |