assertSame(['g7_users', 'g7_migrations'], $result); } public function test_preserves_non_prefixed_tables(): void { $tables = ['wp_posts', 'wp_users', 'legacy_orders']; $result = filterTablesByPrefix($tables, 'g7_'); $this->assertSame([], $result, 'prefix 가 다른 테이블은 삭제 대상에서 제외되어야 한다'); } public function test_supports_custom_prefix(): void { $tables = ['shop_users', 'shop_products', 'g7_users', 'other_table']; $result = filterTablesByPrefix($tables, 'shop_'); $this->assertSame(['shop_users', 'shop_products'], $result); } public function test_empty_prefix_returns_no_tables(): void { $tables = ['g7_users', 'wp_posts', 'anything']; $result = filterTablesByPrefix($tables, ''); $this->assertSame( [], $result, '빈 prefix 는 전체 일치로 모든 테이블이 삭제되는 위험이 있어 빈 목록을 반환해야 한다' ); } public function test_empty_table_list_returns_empty(): void { $result = filterTablesByPrefix([], 'g7_'); $this->assertSame([], $result); } public function test_returns_sequentially_indexed_array(): void { // array_filter 가 원본 키를 보존하지 않도록 재인덱싱되어야 한다 (foreach DROP 안정성) $tables = ['other_a', 'g7_users', 'other_b', 'g7_posts']; $result = filterTablesByPrefix($tables, 'g7_'); $this->assertSame([0, 1], array_keys($result)); $this->assertSame(['g7_users', 'g7_posts'], $result); } public function test_prefix_must_match_at_start_not_substring(): void { // 중간에 prefix 문자열을 포함하는 테이블은 삭제 대상이 아니다 $tables = ['my_g7_data', 'g7_users']; $result = filterTablesByPrefix($tables, 'g7_'); $this->assertSame(['g7_users'], $result); } }