From 19338d2a581eebed75ef9b0e3e5e415c55ca50e4 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sun, 5 Jan 2025 14:58:30 +0100 Subject: [PATCH] subscriber lists are always from same type --- src/Resources/Subscriber.php | 6 ++++-- tests/integration/Resources/SubscriberTest.php | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Resources/Subscriber.php b/src/Resources/Subscriber.php index d69050d..db8046d 100644 --- a/src/Resources/Subscriber.php +++ b/src/Resources/Subscriber.php @@ -220,9 +220,9 @@ class Subscriber extends Model /** * @throws BaseException */ - public function tagged(string $tagId): array + public function tagged(string $tagId): SubscriberList { - return $this->connection->requestAndParse( + $data = $this->connection->requestAndParse( 'POST', 'subscriber/tagged.json', [ @@ -231,6 +231,8 @@ class Subscriber extends Model ], ] ) ?? []; + + return new SubscriberList($data); } /** diff --git a/tests/integration/Resources/SubscriberTest.php b/tests/integration/Resources/SubscriberTest.php index 13f598d..80d42e8 100644 --- a/tests/integration/Resources/SubscriberTest.php +++ b/tests/integration/Resources/SubscriberTest.php @@ -413,14 +413,14 @@ class SubscriberTest extends IntegrationTestCase $this->expectException(BaseException::class); } - $this->assertEquals( - $expected, - $this->callMethod( - $sut, - 'tagged', - ['2354758'] - ) + $return = $this->callMethod( + $sut, + 'tagged', + ['2354758'] ); + + $this->assertInstanceOf(SubscriberList::class, $return); + $this->assertSame($expected, $return->toArray()); } public static function taggedDataProvider(): Generator