inti project

This commit is contained in:
root
2026-05-29 04:33:03 -04:00
commit cdeab1796f
699 changed files with 20516 additions and 0 deletions
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);
namespace Tests\Feature\Api;
use App\Support\Api\ApiResponse;
use PHPUnit\Framework\TestCase;
final class Phase8ApiEnvelopeTest extends TestCase
{
public function test_api_response_class_exists(): void
{
$this->assertTrue(class_exists(ApiResponse::class));
}
public function test_route_inventory_fixture_exists(): void
{
$path = dirname(__DIR__, 3).'/storage/app/generated/api-route-inventory.json';
$this->assertFileExists($path);
$this->assertStringContainsString('api.v2', file_get_contents($path));
}
}
@@ -0,0 +1,22 @@
<?php
namespace Tests\Feature\Release;
use App\Support\Release\FeatureFlagRegistry;
use PHPUnit\Framework\TestCase;
final class FeatureFlagRolloutMapTest extends TestCase
{
public function test_high_risk_flags_have_owners_and_safe_defaults(): void
{
$registry = new FeatureFlagRegistry();
$flags = $registry->export();
$this->assertNotEmpty($flags);
foreach ($flags as $flag) {
$this->assertNotSame('', $flag['owner']);
$this->assertArrayHasKey('default', $flag);
}
}
}
@@ -0,0 +1,22 @@
<?php
namespace Tests\Feature\Release;
use App\Support\Release\MigrationValidationRunner;
use PHPUnit\Framework\TestCase;
final class MigrationValidationScaffoldTest extends TestCase
{
public function test_validation_runner_defines_required_module_checks(): void
{
$runner = new MigrationValidationRunner();
$modules = array_map(fn ($result): string => $result->module, $runner->runAll());
$this->assertContains('finance', $modules);
$this->assertContains('attendance', $modules);
$this->assertContains('students', $modules);
$this->assertContains('communication', $modules);
$this->assertContains('reporting', $modules);
$this->assertContains('islamic_sunday_school', $modules);
}
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\SchoolCore\Attendance;
use PHPUnit\Framework\TestCase;
final class ScannerDelegationTest extends TestCase
{
public function test_scanner_route_file_exists_for_phase_four_slice(): void
{
$routeFile = dirname(__DIR__, 3).'/routes/attendance_phase4.php';
$this->assertFileExists($routeFile);
$this->assertStringContainsString('attendance.scan.process', file_get_contents($routeFile));
}
}
@@ -0,0 +1 @@
<?php declare(strict_types=1); namespace Tests\Feature\SchoolCore\Communication; use App\Domain\SchoolCore\Communication\Exceptions\RecipientPreviewRequiredException; use PHPUnit\Framework\TestCase; final class BulkSendRequiresPreviewTest extends TestCase { public function test_bulk_send_without_preview_exception_exists(): void { $this->assertTrue(class_exists(RecipientPreviewRequiredException::class)); } }
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\SchoolCore\Finance;
use PHPUnit\Framework\TestCase;
final class PaymentFileRouteTest extends TestCase
{
public function test_phase3_route_documents_payment_id_based_file_access(): void
{
$routes = file_get_contents(__DIR__ . '/../../../routes/finance_phase3.php');
$this->assertStringContainsString('payments/{payment}/file', $routes);
$this->assertStringContainsString('school.context', $routes);
}
}
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\SchoolCore;
use App\Domain\SchoolCore\Context\SchoolContext;
use App\Domain\SchoolCore\Files\Policies\PaymentFileAccessPolicy;
use PHPUnit\Framework\TestCase;
final class PaymentFilePolicyTest extends TestCase
{
public function test_cross_school_payment_file_access_fails(): void
{
$context = new SchoolContext(10, 20, ['finance'], '2025', 'spring', 'UTC', 'en', 'USD', 'standard_school');
$policy = new PaymentFileAccessPolicy();
$this->assertFalse($policy->canAccess($context, 'payment', 99, ['school_id' => 11]));
}
public function test_finance_role_can_access_same_school_payment_file(): void
{
$context = new SchoolContext(10, 20, ['finance'], '2025', 'spring', 'UTC', 'en', 'USD', 'standard_school');
$policy = new PaymentFileAccessPolicy();
$this->assertTrue($policy->canAccess($context, 'payment', 99, ['school_id' => 10]));
}
}
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class ReportingPhase7ScaffoldTest extends TestCase
{
public function test_reporting_phase_7_scaffold_exists(): void
{
$root = dirname(__DIR__, 3);
$this->assertFileExists($root.'/app/Domain/SchoolCore/Reporting/Contracts/ReportRunnerContract.php');
$this->assertFileExists($root.'/app/Providers/SchoolCoreReportingServiceProvider.php');
$this->assertFileExists($root.'/app/Domain/IslamicSundaySchool/Reporting/Providers/IslamicSundaySchoolReportingServiceProvider.php');
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\SchoolCore;
use App\Domain\SchoolCore\Context\SchoolContext;
use App\Http\Middleware\ResolveSchoolContext;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Orchestra\Testbench\TestCase;
final class ResolveSchoolContextMiddlewareTest extends TestCase
{
protected function getPackageProviders($app): array
{
return [\App\Providers\SchoolContextServiceProvider::class];
}
public function test_it_attaches_context_to_request(): void
{
$request = Request::create('/test', 'GET');
$request->setUserResolver(fn () => new MiddlewareFakeUser(5, 88));
$middleware = app(ResolveSchoolContext::class);
$response = $middleware->handle($request, function (Request $request) {
return response()->json([
'school_id' => $request->attributes->get(SchoolContext::class)->schoolId,
]);
});
$this->assertSame(200, $response->getStatusCode());
$this->assertStringContainsString('5', $response->getContent());
}
}
final class MiddlewareFakeUser implements Authenticatable
{
public function __construct(public int $school_id, private int $id)
{
}
public function getAuthIdentifierName(): string { return 'id'; }
public function getAuthIdentifier(): mixed { return $this->id; }
public function getAuthPassword(): string { return ''; }
public function getAuthPasswordName(): string { return 'password'; }
public function getRememberToken(): ?string { return null; }
public function setRememberToken($value): void {}
public function getRememberTokenName(): string { return 'remember_token'; }
}
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\SchoolCore;
use PHPUnit\Framework\TestCase;
final class StudentIdentifierConcurrencyTest extends TestCase
{
public function test_database_must_enforce_unique_student_identifier_per_school(): void
{
$this->markTestSkipped('Enable in the host Laravel app after binding the real Student model and database connection. The migration adds unique(school_id, school_id_number).');
}
}
@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\SchoolCore\Students;
use PHPUnit\Framework\TestCase;
final class StudentLifecycleDelegationTest extends TestCase { public function test_phase5_routes_file_exists(): void { $this->assertFileExists(dirname(__DIR__,3).'/routes/student_lifecycle_phase5.php'); } }