Files
compras/tests/Pest.php
T
nalaandClaude Opus 5.5 8e1e8799a5 Tornar a suite de testes portável e alinhada com o código
- sgfTempoPath(): substitui caminhos C:/laragon fixos (SGF_TEMPO_ROOT, por
  omissão a pasta irmã sgf-tempo, igual ao Laragon).
- skipUnlessIsolatedPostgres(): testes que exigem a base QA PostgreSQL isolada
  passam a ser ignorados com motivo em SQLite em vez de rebentar.
- Artefacto de distribuição orçamental gerado localmente: ignorado se ausente.
- Páginas públicas /consulta e /proposta: testes alinhados com os
  redireccionamentos para os módulos reais (decisão de 29/11).
- Impressão da ordem: texto do aviso orçamental actualizado.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 23:01:36 +02:00

70 lines
2.5 KiB
PHP

<?php
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "pest()" function to bind different classes or traits.
|
*/
pest()->extend(TestCase::class)
->use(RefreshDatabase::class)
->in('Feature');
// A separate invocation is required for the unpublished inventory contract; Feature has a process wrapper.
pest()->extend(TestCase::class)->use(RefreshDatabase::class)->in('Conversion');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/
expect()->extend('toBeOne', function () {
return $this->toBe(1);
});
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/
/**
* Root of the sibling SGF checkout (common finance sources), portable across machines.
* Defaults to the folder next to this repository, e.g. C:/laragon/www/sgf-tempo on Laragon.
*/
function sgfTempoPath(string $relative = ''): string
{
$root = getenv('SGF_TEMPO_ROOT') ?: dirname(__DIR__, 2).'/sgf-tempo';
$path = rtrim(str_replace('\\', '/', $root), '/');
return $relative === '' ? $path : $path.'/'.ltrim($relative, '/');
}
/** Tests that assert the identity of an isolated PostgreSQL QA database cannot run on SQLite. */
function skipUnlessIsolatedPostgres(PHPUnit\Framework\TestCase $test): void
{
if (DB::connection()->getDriverName() !== 'pgsql') {
$test->markTestSkipped('Requires the isolated PostgreSQL QA database (see tests/Concurrency).');
}
}