40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Architecture;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use RecursiveDirectoryIterator;
|
|
use RecursiveIteratorIterator;
|
|
use SplFileInfo;
|
|
|
|
final class SchoolCoreArchitectureTest extends TestCase
|
|
{
|
|
public function test_school_core_does_not_use_hidden_context_sources(): void
|
|
{
|
|
$forbidden = ['auth(', 'request(', 'Configuration::getConfig(', 'App\\Domain\\IslamicSundaySchool'];
|
|
$root = app_path('Domain/SchoolCore');
|
|
|
|
if (! is_dir($root)) {
|
|
$this->markTestSkipped('SchoolCore directory not present in this test installation.');
|
|
}
|
|
|
|
$violations = [];
|
|
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)) as $file) {
|
|
if (! $file instanceof SplFileInfo || $file->getExtension() !== 'php') {
|
|
continue;
|
|
}
|
|
|
|
$contents = file_get_contents($file->getPathname()) ?: '';
|
|
foreach ($forbidden as $needle) {
|
|
if (str_contains($contents, $needle)) {
|
|
$violations[] = $file->getPathname() . ' contains ' . $needle;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->assertSame([], $violations);
|
|
}
|
|
}
|