update project
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Architecture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class Phase4AttendanceArchitectureTest extends TestCase
|
||||
{
|
||||
public function test_school_core_attendance_does_not_depend_on_islamic_sunday_school(): void
|
||||
{
|
||||
foreach ($this->phpFiles('app/Domain/SchoolCore/Attendance') as $file) {
|
||||
$contents = file_get_contents($file);
|
||||
$this->assertStringNotContainsString('App\\Domain\\IslamicSundaySchool', $contents, $file);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_school_core_attendance_does_not_use_request_or_auth_helpers(): void
|
||||
{
|
||||
foreach ($this->phpFiles('app/Domain/SchoolCore/Attendance') as $file) {
|
||||
$contents = file_get_contents($file);
|
||||
$this->assertStringNotContainsString('Illuminate\\Http\\Request', $contents, $file);
|
||||
$this->assertStringNotContainsString('auth()', $contents, $file);
|
||||
$this->assertStringNotContainsString('request()', $contents, $file);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_school_core_attendance_contracts_remain_neutral(): void
|
||||
{
|
||||
$forbidden = ['masjid', 'ministry', 'quran', 'arabic', 'halaqa'];
|
||||
|
||||
foreach ($this->phpFiles('app/Domain/SchoolCore/Attendance/Contracts') as $file) {
|
||||
$contents = strtolower((string) file_get_contents($file));
|
||||
foreach ($forbidden as $word) {
|
||||
$this->assertStringNotContainsString($word, $contents, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_scanner_controller_is_thin(): void
|
||||
{
|
||||
$file = dirname(__DIR__, 2).'/app/Http/Controllers/Attendance/ScannerController.php';
|
||||
$contents = file_get_contents($file);
|
||||
$this->assertStringNotContainsString('private function', $contents);
|
||||
$this->assertStringContainsString('ScannerServiceContract', $contents);
|
||||
}
|
||||
|
||||
private function phpFiles(string $relativePath): array
|
||||
{
|
||||
$base = dirname(__DIR__, 2).'/'.$relativePath;
|
||||
if (! is_dir($base)) {
|
||||
return [];
|
||||
}
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($base));
|
||||
$files = [];
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile() && $file->getExtension() === 'php') {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user