[파일 경로] */ public static function extensionTestCaseProvider(): array { $patterns = [ 'modules/_bundled/*/tests/ModuleTestCase.php', 'plugins/_bundled/*/tests/PluginTestCase.php', 'templates/_bundled/*/tests/TemplateTestCase.php', ]; $cases = []; foreach ($patterns as $pattern) { foreach (glob(self::repositoryRoot().DIRECTORY_SEPARATOR.$pattern) ?: [] as $path) { $source = file_get_contents($path); // migrateFreshUsing 을 재정의하지 않는 TestCase 는 코어 기본 스키마를 쓰므로 대상 아님 if (! str_contains($source, 'function migrateFreshUsing')) { continue; } $relative = str_replace(self::repositoryRoot().DIRECTORY_SEPARATOR, '', $path); $cases[$relative] = [$path]; } } return $cases; } /** * 모든 확장 TestCase 가 번들 모듈·플러그인 마이그레이션을 전부 포함한다. * * @param string $path TestCase 파일 절대 경로 */ #[DataProvider('extensionTestCaseProvider')] public function test_extension_test_case_includes_all_bundled_migrations(string $path): void { $source = file_get_contents($path); $relative = str_replace(self::repositoryRoot().DIRECTORY_SEPARATOR, '', $path); foreach (['modules/_bundled/*/database/migrations', 'plugins/_bundled/*/database/migrations'] as $globPattern) { $this->assertStringContainsString( $globPattern, $source, "{$relative} 의 migrateFreshUsing() 이 '{$globPattern}' 을 포함하지 않습니다. " .'이 TestCase 가 프로세스에서 먼저 실행되면 다른 확장의 테이블이 생성되지 않아 ' .'스위트를 묶어 돌릴 때 "Base table or view not found" 가 발생합니다.' ); } } /** * 자기 확장 경로만 하드코딩한 잔재가 없다. * * glob 을 도입하면서 옛 하드코딩 줄을 지우지 않으면 경로가 중복될 뿐 결함은 남지 않지만, * glob 없이 하드코딩만 있는 상태로 되돌아가는 회귀는 위 단언이 잡는다. 이 단언은 그 * 되돌림이 "자기 확장만 나열" 형태로 재등장하는 것을 추가로 막는다. * * @param string $path TestCase 파일 절대 경로 */ #[DataProvider('extensionTestCaseProvider')] public function test_extension_test_case_does_not_pin_only_its_own_migrations(string $path): void { $source = file_get_contents($path); $relative = str_replace(self::repositoryRoot().DIRECTORY_SEPARATOR, '', $path); // 예: 'plugins/sirsoft-ckeditor5/database/migrations' 처럼 와일드카드 없는 단일 확장 경로 $pinned = preg_match( "#['\"](modules|plugins)/(?!_bundled/\*)[a-z0-9_-]+/database/migrations['\"]#i", $source ); $this->assertSame( 0, $pinned, "{$relative} 이 특정 확장의 마이그레이션 경로를 직접 지정하고 있습니다. " .'번들 확장 전체를 glob 으로 포함하세요.' ); } }