createMock(ClientInterface::class); $httpClient->expects(self::once()) ->method('request') ->with( 'GET', 'https://musicbrainz.org/ws/2/release/' . $releaseId, self::callback(static function (array $options): bool { $query = $options['query'] ?? []; return ($query['fmt'] ?? null) === 'json'; }) ) ->willReturn(new Response(200, ['Content-Type' => 'application/json'], json_encode([ 'id' => $releaseId, 'title' => 'Reference Album', 'artist-credit' => [ ['name' => 'Reference Artist'], ], 'media' => [[ 'position' => 1, 'tracks' => [[ 'id' => 'track-1', 'number' => '1', 'title' => 'Reference Track', 'length' => 180000, ]], ]], // External storefront URL should not be used as the "Open Source" link. 'relations' => [[ 'url' => ['resource' => 'https://store.example.test/reference-album'], ]], ], JSON_THROW_ON_ERROR))); $settings = $this->createMock(SettingRepository::class); $cache = new ArrayAdapter(); $client = new MusicBrainzClient($httpClient, $cache, $settings); $album = $client->getAlbumWithTracks('mbid:' . $releaseId); self::assertIsArray($album); self::assertSame( 'https://musicbrainz.org/release/' . $releaseId, $album['external_urls']['external'] ?? null ); } }