header:navbar e footer
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-19 13:07:16 +02:00
parent 3ca67a53c1
commit 14ad2f60c5
34 changed files with 1631 additions and 410 deletions
@@ -0,0 +1,35 @@
<?php
namespace Tests\Feature;
use App\Support\IsolatedQaDatabase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class DevelopmentEnvironmentTest extends TestCase
{
use RefreshDatabase;
public function test_the_verified_qa_connection_can_prepare_its_schema(): void
{
$this->assertTrue(IsolatedQaDatabase::allowsSchemaChanges());
$this->artisan('portal:dev-check')->assertSuccessful();
}
public function test_an_active_environment_is_never_treated_as_qa(): void
{
$this->app->instance('env', 'production');
$this->assertFalse(IsolatedQaDatabase::allowsSchemaChanges());
}
public function test_invalid_targets_and_a_mismatched_real_database_are_refused(): void
{
$original = config('database.connections.pgsql');
foreach (['host' => 'remote.example', 'port' => '5432', 'database' => 'investemoz', 'url' => 'pgsql://remote.example/qa_test'] as $key => $value) {
config(['database.connections.pgsql' => [...$original, $key => $value]]);
$this->assertFalse(IsolatedQaDatabase::allowsSchemaChanges(), $key);
}
config(['database.connections.pgsql' => [...$original, 'database' => 'different_qa_test']]);
$this->assertFalse(IsolatedQaDatabase::allowsSchemaChanges());
}
}
@@ -0,0 +1,20 @@
<?php
namespace Tests\Unit;
use App\Services\EconomicReferenceCatalog;
use PHPUnit\Framework\TestCase;
class EconomicReferenceManifestTest extends TestCase
{
public function test_the_distributed_manifest_matches_the_existing_approved_byte_hash(): void
{
$path = dirname(__DIR__, 2).'/database/data/economic-references-lot-01.json';
$this->assertSame(EconomicReferenceCatalog::MANIFEST_SHA256, hash_file('sha256', $path));
$manifest = json_decode(file_get_contents($path), true, 512, JSON_THROW_ON_ERROR);
$this->assertSame(EconomicReferenceCatalog::LOT, $manifest['lot']);
$this->assertCount(5, $manifest['activities']);
$this->assertCount(5, $manifest['chains']);
$this->assertCount(4, $manifest['links']);
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Tests\Unit;
use Illuminate\Filesystem\Filesystem;
use PHPUnit\Framework\TestCase;
class RuntimeStorageTest extends TestCase
{
public function test_missing_runtime_directories_are_created_without_changing_existing_files(): void
{
$root = sys_get_temp_dir().'/investmoz-runtime-'.bin2hex(random_bytes(8));
$prepare = require dirname(__DIR__, 2).'/bootstrap/storage.php';
try {
$prepare($root, $root.'/custom-storage');
foreach (['app/private', 'app/public', 'framework/cache/data', 'framework/sessions', 'framework/views', 'logs'] as $path) {
$this->assertDirectoryExists($root.'/custom-storage/'.$path);
}
$this->assertDirectoryExists($root.'/bootstrap/cache');
$file = $root.'/custom-storage/framework/views/existing.php';
file_put_contents($file, 'preserved');
$prepare($root, $root.'/custom-storage');
$this->assertSame('preserved', file_get_contents($file));
$this->assertNotFalse(realpath($root.'/custom-storage/framework/views'));
} finally {
(new Filesystem)->deleteDirectory($root);
}
}
public function test_a_file_blocking_a_runtime_directory_produces_an_actionable_error(): void
{
$root = sys_get_temp_dir().'/investmoz-runtime-'.bin2hex(random_bytes(8));
mkdir($root, 0775, true);
file_put_contents($root.'/storage', 'preserved');
$prepare = require dirname(__DIR__, 2).'/bootstrap/storage.php';
try {
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Cannot create Laravel runtime directory:');
$prepare($root, $root.'/storage');
} finally {
$this->assertSame('preserved', file_get_contents($root.'/storage'));
(new Filesystem)->deleteDirectory($root);
}
}
}