@@ -92,6 +92,9 @@ $environment = ['APP_ENV' => 'testing', 'APP_DEBUG' => 'false', 'APP_KEY' => con
|
||||
'MAIL_MAILER' => 'array', 'QUEUE_CONNECTION' => 'sync', 'BROADCAST_CONNECTION' => 'null', 'BCRYPT_ROUNDS' => '4',
|
||||
'COMMON_BUDGET_PATH' => 'C:/laragon/www/sgf-tempo/packages/budget-control', 'SGC_BUDGET_DISTRIBUTIONS_QA_ENABLED' => 'true',
|
||||
'SGC_DISTRIBUTION_QA_PUBLIC' => $private.'/public'];
|
||||
if (in_array('--order-parts', $argv, true)) {
|
||||
$environment['SGC_ORDER_PARTS_QA_ENABLED'] = 'true';
|
||||
}
|
||||
file_put_contents($private.'/settings.json', json_encode($environment, JSON_THROW_ON_ERROR));
|
||||
config(['database.connections.distribution_visual_admin' => [...$config, 'database' => 'postgres', 'url' => null]]);
|
||||
$admin = DB::connection('distribution_visual_admin');
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Support\Str;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
require_once __DIR__.'/../tests/Support/LandedQaReceipts.php';
|
||||
$app = require dirname(__DIR__).'/bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
$config = DB::connection('pgsql')->getConfig();
|
||||
@@ -20,6 +21,7 @@ if (! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', $database) || $datab
|
||||
config(['database.connections.quotation_fx_admin' => [...$config, 'database' => 'postgres', 'url' => null]]);
|
||||
$admin = DB::connection('quotation_fx_admin');
|
||||
$admin->statement('CREATE DATABASE "'.$database.'"');
|
||||
$qaVerificationFailed = false;
|
||||
try {
|
||||
$environment = ['APP_ENV' => 'testing', 'DB_CONNECTION' => 'pgsql', 'DB_URL' => '', 'DB_HOST' => $config['host'],
|
||||
'DB_PORT' => (string) $config['port'], 'DB_DATABASE' => $database, 'DB_USERNAME' => $config['username'],
|
||||
@@ -52,13 +54,42 @@ try {
|
||||
$savedSearchesMode = in_array('--saved-searches-only', $argv, true);
|
||||
$categoryApprovalsMode = in_array('--category-approvals-only', $argv, true);
|
||||
$orderPartsMode = in_array('--budget-order-parts-only', $argv, true);
|
||||
$landedCostsMode = in_array('--import-landed-costs-only', $argv, true);
|
||||
if ($landedCostsMode) {
|
||||
$environment['COMMON_BUDGET_PATH'] = 'C:/laragon/www/sgf-tempo/packages/budget-control';
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/ImportLandedCostPlanTest.php', 'tests/Feature/ImportLandedCostsTest.php', 'tests/Feature/BudgetLandedCostsContractTest.php',
|
||||
'tests/Feature/SupplyPlanningTest.php', 'tests/Feature/BudgetDistributionContractTest.php', 'tests/Feature/BudgetOrderPartsContractTest.php', 'tests/Feature/BudgetTest.php', 'tests/Feature/BudgetReinforcementTest.php', 'tests/Feature/InvoiceTest.php', 'tests/Feature/OperationalHealthTest.php']];
|
||||
if (in_array('--native-financial-focused', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/ImportLandedCostsTest.php', '--filter=native independently reviewed cost plan']];
|
||||
}
|
||||
if (in_array('--tariffs-focused', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/ImportTariffCodesTest.php', 'tests/Feature/RequisitionCatalogueTest.php']];
|
||||
}
|
||||
if (in_array('--tariff-orders-focused', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', 'tests/Feature/SupplyPlanningTest.php', 'tests/Feature/ReceiptStockTest.php', '--filter=confirmed import classifications|imported item classification|native partial-order|native consolidated order|import tracking|receipt|stock']];
|
||||
if (in_array('--catalogue-receipt-focused', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', '--filter=catalogue origin survives order issue']];
|
||||
}
|
||||
}
|
||||
if (in_array('--tariff-order-regression', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', '--filter=foreign|discount evidence|admission basis changes|expired after approval|older synthetic']];
|
||||
}
|
||||
if (in_array('--landed-concurrency', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
|
||||
[PHP_BINARY, 'tests/Concurrency/budget-landed-cost-worker.php', $database, 'race']];
|
||||
}
|
||||
if (in_array('--landed-recovery', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
|
||||
[PHP_BINARY, 'tests/Concurrency/budget-distribution-recovery-worker.php', $database, 'landed-costs']];
|
||||
}
|
||||
}
|
||||
if ($orderPartsMode) {
|
||||
$environment['COMMON_BUDGET_PATH'] = 'C:/laragon/www/sgf-tempo/packages/budget-control';
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/BudgetOrderPartsContractTest.php', 'tests/Feature/BudgetDistributionContractTest.php', 'tests/Feature/BudgetTest.php', 'tests/Feature/BudgetReinforcementTest.php']];
|
||||
if (in_array('--order-parts-native', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/BudgetOrderPartsContractTest.php',
|
||||
'tests/Feature/InvoiceTest.php', 'tests/Unit/PurchaseLineAmountsTest.php', 'tests/Feature/PurchaseAwardOrderTest.php',
|
||||
'--filter=BudgetOrderPartsContractTest|InvoiceTest|PurchaseLineAmountsTest|optional partial-order']];
|
||||
'--filter=BudgetOrderPartsContractTest|InvoiceTest|PurchaseLineAmountsTest|optional partial-order|native partial-order|native consolidated order|native explicit adoption']];
|
||||
}
|
||||
if (in_array('--order-parts-recovery', $argv, true)) {
|
||||
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
|
||||
@@ -139,6 +170,9 @@ try {
|
||||
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/SupplierBankAccountsTest.php', 'tests/Feature/SupplierBankTest.php',
|
||||
'tests/Feature/ExternalPaymentTest.php', 'tests/Feature/PaymentIntegrationTest.php', 'tests/Feature/QuotationExchangeFinanceTest.php']];
|
||||
}
|
||||
if ($landedCostsMode && ! landedQaCommandIsolationVerified($commands)) {
|
||||
throw new LogicException('Each Pest kernel must use its own disposable PostgreSQL database.');
|
||||
}
|
||||
foreach ($commands as $command) {
|
||||
$process = new Process($command, dirname(__DIR__), $environment, timeout: 180);
|
||||
$process->run();
|
||||
@@ -147,8 +181,15 @@ try {
|
||||
echo $process->getErrorOutput();
|
||||
throw new RuntimeException('Validação PostgreSQL não aprovada.');
|
||||
}
|
||||
if ($landedCostsMode) {
|
||||
$verified = landedQaReceiptsVerified($command, $process->getOutput());
|
||||
if (! $verified) {
|
||||
echo $process->getErrorOutput();
|
||||
throw new RuntimeException('O processo terminou sem os recibos obrigatórios de verificação QA.');
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($conversionMode || $agreementMode || $orderLimitMode || $upgradeMode || $benchmarkMode || $draftMode || $searchMode || $productionMode || $configuredLevelsMode || $orderDocumentMode || $payableInsightsMode || $budgetDistributionMode || $categoriesMode || $savedSearchesMode || $categoryApprovalsMode || $orderPartsMode) {
|
||||
if ($conversionMode || $agreementMode || $orderLimitMode || $upgradeMode || $benchmarkMode || $draftMode || $searchMode || $productionMode || $configuredLevelsMode || $orderDocumentMode || $payableInsightsMode || $budgetDistributionMode || $categoriesMode || $savedSearchesMode || $categoryApprovalsMode || $orderPartsMode || $landedCostsMode) {
|
||||
return;
|
||||
}
|
||||
config(['database.connections.quotation_fx_proof' => [...$config, 'database' => $database, 'url' => null]]);
|
||||
@@ -239,7 +280,13 @@ try {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable $error) {
|
||||
$qaVerificationFailed = true;
|
||||
echo json_encode(['qa_verification_failed' => true, 'message' => $error->getMessage()], JSON_THROW_ON_ERROR).PHP_EOL;
|
||||
} finally {
|
||||
$admin->statement('DROP DATABASE "'.$database.'" WITH (FORCE)');
|
||||
echo json_encode(['database' => $database, 'isolated_database_removed' => true], JSON_THROW_ON_ERROR).PHP_EOL;
|
||||
}
|
||||
if ($qaVerificationFailed) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user