File tree Expand file tree Collapse file tree 3 files changed +37
-4
lines changed
tests/Unit/ServerNotifications Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Imdhemy \Purchases \Contracts ;
4+
5+ interface HasSubtype
6+ {
7+ /**
8+ * Gets subscription subtype
9+ *
10+ * @return string
11+ */
12+ public function getSubtype (): string ;
13+ }
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Client ;
66use Imdhemy \AppStore \ServerNotifications \V2DecodedPayload ;
7+ use Imdhemy \Purchases \Contracts \HasSubtype ;
78use Imdhemy \Purchases \Contracts \ServerNotificationContract ;
89use Imdhemy \Purchases \Contracts \SubscriptionContract ;
910use Imdhemy \Purchases \Subscriptions \AppleSubscription ;
1011
11- class AppStoreV2ServerNotification implements ServerNotificationContract
12+ class AppStoreV2ServerNotification implements ServerNotificationContract, HasSubtype
1213{
1314 /**
1415 * @var V2DecodedPayload
@@ -80,4 +81,14 @@ public function getPayload(): array
8081 {
8182 return $ this ->payload ->toArray ();
8283 }
84+
85+ /**
86+ * Gets subscription subtype
87+ *
88+ * @return string
89+ */
90+ public function getSubtype (): string
91+ {
92+ return (string )$ this ->payload ->getSubType ();
93+ }
8394}
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ protected function setUp(): void
2020 parent ::setUp ();
2121
2222 $ claims = [
23- 'notificationType ' => V2DecodedPayload::TYPE_TEST ,
23+ 'notificationType ' => V2DecodedPayload::TYPE_SUBSCRIBED ,
24+ 'subtype ' => V2DecodedPayload::SUBTYPE_INITIAL_BUY ,
2425 'data ' => [
2526 'bundleId ' => 'com.example.app ' ,
2627 ],
@@ -36,7 +37,7 @@ protected function setUp(): void
3637 */
3738 public function get_type (): void
3839 {
39- $ this ->assertEquals (V2DecodedPayload::TYPE_TEST , $ this ->sut ->getType ());
40+ $ this ->assertEquals (V2DecodedPayload::TYPE_SUBSCRIBED , $ this ->sut ->getType ());
4041 }
4142
4243 /**
@@ -55,7 +56,7 @@ public function get_subscription(): void
5556 */
5657 public function is_test (): void
5758 {
58- $ this ->assertTrue ($ this ->sut ->isTest ());
59+ $ this ->assertFalse ($ this ->sut ->isTest ());
5960 }
6061
6162 /**
@@ -73,4 +74,12 @@ public function get_payload(): void
7374 {
7475 $ this ->assertSame ($ this ->payload ->toArray (), $ this ->sut ->getPayload ());
7576 }
77+
78+ /**
79+ * @test
80+ */
81+ public function get_subtype (): void
82+ {
83+ $ this ->assertEquals (V2DecodedPayload::SUBTYPE_INITIAL_BUY , $ this ->sut ->getSubtype ());
84+ }
7685}
You can’t perform that action at this time.
0 commit comments