36 lines
1.6 KiB
PHP
36 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Modules\Purchasing\BudgetAdapter;
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
// Test harness only. Uses the SGF HTTP stack, sessions, CSRF and context middleware.
|
|
$host = getenv('IR_SGF_HOST');
|
|
$candidate = getenv('IR_CANDIDATE_ROOT');
|
|
require $host.'/vendor/autoload.php';
|
|
$app = require $host.'/bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
config(['logging.default' => 'single', 'logging.channels.single.path' => getenv('IR_WORK_DIR').'/candidate-errors.log']);
|
|
BudgetAdapter::guard();
|
|
require $candidate.'/integrations/sgf/internal-requisitions/bootstrap.php';
|
|
require $candidate.'/integrations/sgf/internal-requisitions/routes.php';
|
|
$fault = getenv('IR_FAULT_FILE');
|
|
if (is_file($fault) && trim(file_get_contents($fault)) === 'before_commit') {
|
|
DB::listen(function ($query) use ($fault) {
|
|
if (str_contains($query->sql, 'insert into "ir_events"') && in_array('submitted', $query->bindings, true)) {
|
|
unlink($fault);
|
|
throw new RuntimeException('Injected failure before commit');
|
|
}
|
|
});
|
|
}
|
|
$request = Request::capture();
|
|
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
|
$response = $kernel->handle($request);
|
|
if (is_file($fault) && trim(file_get_contents($fault)) === 'lost_response' && $request->isMethod('POST') && $request->is('api/internal-requisitions/*')) {
|
|
unlink($fault);
|
|
$response = response()->json(['message' => 'Injected lost response after commit'], 500);
|
|
}
|
|
$response->send();
|
|
$kernel->terminate($request, $response);
|