diff --git a/tests/Integration/Messaging/AppInstanceTest.php b/tests/Integration/Messaging/AppInstanceTest.php index b94ccd87..3b7ea387 100644 --- a/tests/Integration/Messaging/AppInstanceTest.php +++ b/tests/Integration/Messaging/AppInstanceTest.php @@ -5,6 +5,7 @@ namespace Kreait\Firebase\Tests\Integration\Messaging; use Kreait\Firebase\Contract\Messaging; +use Kreait\Firebase\Messaging\AppInstance; use Kreait\Firebase\Messaging\RegistrationToken; use Kreait\Firebase\Tests\IntegrationTestCase; use PHPUnit\Framework\Attributes\Test; @@ -37,18 +38,28 @@ public function itIsSubscribedToTopics(): void $this->messaging->subscribeToTopic($secondTopic, RegistrationToken::fromValue($token)); // Lazy registration token test $this->messaging->subscribeToTopic($thirdTopic, $token); - $instance = $this->messaging->getAppInstance($token); - - $this->assertTrue($instance->isSubscribedToTopic($firstTopic)); - $this->assertTrue($instance->isSubscribedToTopic($secondTopic)); + $this->assertTrue($this->appInstance($token)->isSubscribedToTopic($firstTopic)); + $this->assertTrue($this->appInstance($token)->isSubscribedToTopic($secondTopic)); + $this->assertTrue($this->appInstance($token)->isSubscribedToTopic($thirdTopic)); $this->messaging->unsubscribeFromTopic($firstTopic, $token); + $this->assertFalse($this->appInstance($token)->isSubscribedToTopic($firstTopic)); + $this->assertTrue($this->appInstance($token)->isSubscribedToTopic($secondTopic)); + $this->assertTrue($this->appInstance($token)->isSubscribedToTopic($thirdTopic)); + $this->messaging->unsubscribeFromTopic($secondTopic, $token); - $this->messaging->unsubscribeFromAllTopics($token); + $this->assertFalse($this->appInstance($token)->isSubscribedToTopic($secondTopic)); + $this->assertTrue($this->appInstance($token)->isSubscribedToTopic($thirdTopic)); - $instance = $this->messaging->getAppInstance($token); + $this->messaging->unsubscribeFromAllTopics($token); + $this->assertFalse($this->appInstance($token)->isSubscribedToTopic($thirdTopic)); + } - $this->assertFalse($instance->isSubscribedToTopic($firstTopic)); - $this->assertFalse($instance->isSubscribedToTopic($secondTopic)); + /** + * @param non-empty-string $registrationToken + */ + private function appInstance(string $registrationToken): AppInstance + { + return $this->messaging->getAppInstance($registrationToken); } }