handler( 'posts' ); $terms = $this->handler( 'terms' ); $media = $this->handler( 'media' ); $registry = new ContentHandlerRegistry( array( $media, $posts, $terms ) ); self::assertSame( array( $terms, $posts, $media ), $registry->ordered() ); } public function test_it_rejects_duplicate_buckets(): void { $this->expectException( \InvalidArgumentException::class ); $this->expectExceptionMessage( 'Handler bucket "posts" is already registered.' ); new ContentHandlerRegistry( array( $this->handler( 'posts' ), $this->handler( 'posts' ) ) ); } private function handler( string $bucket ): ContentHandlerInterface { return new class( $bucket ) implements ContentHandlerInterface { private string $bucket; public function __construct( string $bucket ) { $this->bucket = $bucket; } public function bucket(): string { return $this->bucket; } /** * @param array> $records Package records. */ public function importRecords( array $records, SyncContext $context ): SyncResult { return SyncResult::success( array( 'skipped' => count( $records ) ) ); } }; } }