52 lines
2.7 KiB
PHP
52 lines
2.7 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
if (! in_array($argv[1] ?? '', ['test', 'analyse'], true) || basename($root) !== 'portal-investidor') {
|
|
throw new RuntimeException('Explicit local test operation required.');
|
|
}
|
|
$proofDirectory = $root.'/outputs/investment-preparation-20261110';
|
|
if (! is_dir($proofDirectory)) {
|
|
mkdir($proofDirectory, 0700, true);
|
|
}
|
|
$analysisConfiguration = "includes:\n - ../../phpstan.neon\nparameters:\n tmpDir: phpstan-cache\n";
|
|
if (! is_file($proofDirectory.'/phpstan.neon')) {
|
|
file_put_contents($proofDirectory.'/phpstan.neon', $analysisConfiguration);
|
|
}
|
|
foreach (['APP_ENV' => 'testing', 'APP_KEY' => 'base64:'.base64_encode(str_repeat('Q', 32)),
|
|
'APP_CONFIG_CACHE' => $root.'/outputs/investment-preparation-20261110/no-config.php',
|
|
'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441',
|
|
'DB_DATABASE' => 'simulator_fiscal_delta_20261021_test', 'DB_USERNAME' => 'investmoz_test', 'DB_PASSWORD' => '',
|
|
'DB_URL' => '', 'DATABASE_URL' => '', 'CACHE_STORE' => 'array', 'SESSION_DRIVER' => 'array',
|
|
'QUEUE_CONNECTION' => 'sync', 'MAIL_MAILER' => 'array', 'SUITECRM_ENABLED' => 'false'] as $key => $value) {
|
|
putenv($key.'='.$value);
|
|
$_ENV[$key] = $_SERVER[$key] = $value;
|
|
}
|
|
$pdo = new PDO('pgsql:host=127.0.0.1;port=55441;dbname=simulator_fiscal_delta_20261021_test', 'investmoz_test', '');
|
|
$identity = $pdo->query('select current_database() as name,inet_server_port() as port')->fetch(PDO::FETCH_ASSOC);
|
|
if ($identity['name'] !== 'simulator_fiscal_delta_20261021_test' || (int) $identity['port'] !== 55441) {
|
|
throw new RuntimeException('Isolated QA identity required.');
|
|
}
|
|
if ($argv[1] === 'analyse') {
|
|
$argv = ['phpstan', 'analyse', '--no-progress', '--memory-limit=512M', '--configuration='.$root.'/outputs/investment-preparation-20261110/phpstan.neon', 'app/Services/InvestmentPreparationWorkspace.php', 'app/Http/Controllers/InvestmentPreparationController.php', 'app/Services/InvestorPath.php', 'routes/investor-path.php'];
|
|
$_SERVER['argv'] = $argv;
|
|
$_SERVER['argc'] = count($argv);
|
|
require $root.'/vendor/autoload.php';
|
|
require $root.'/vendor/phpstan/phpstan/phpstan';
|
|
exit;
|
|
}
|
|
$case = 'InvestmentPreparationWorkspaceTest';
|
|
$filter = $argv[2] ?? null;
|
|
if ($filter !== null && (strlen($filter) > 128 || ! preg_match('/^[a-zA-Z0-9_|]+$/D', $filter))) {
|
|
throw new RuntimeException('Explicit QA test filter required.');
|
|
}
|
|
$argv = ['phpunit', '-c', 'phpunit.investmoz.xml', '--do-not-cache-result', 'tests/Feature/'.$case.'.php'];
|
|
if ($filter !== null) {
|
|
$argv[] = '--filter';
|
|
$argv[] = $filter;
|
|
}
|
|
$argc = count($argv);
|
|
$_SERVER['argv'] = $argv;
|
|
$_SERVER['argc'] = $argc;
|
|
require $root.'/vendor/autoload.php';
|
|
require $root.'/vendor/phpunit/phpunit/phpunit';
|