Skip to content

Commit 49a883f

Browse files
authored
Merge pull request #45 from imdhemy/develop
2 parents b1677c4 + 9df4ce4 commit 49a883f

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

config/purchase.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Imdhemy\Purchases\Events\AppStore\InteractiveRenewal;
1111
use Imdhemy\Purchases\Events\AppStore\PriceIncreaseConsent;
1212
use Imdhemy\Purchases\Events\AppStore\Refund;
13+
use Imdhemy\Purchases\Events\AppStore\Revoke;
1314
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionCanceled;
1415
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionDeferred;
1516
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionExpired;
@@ -66,5 +67,6 @@
6667
InteractiveRenewal::class => [],
6768
PriceIncreaseConsent::class => [],
6869
Refund::class => [],
70+
Revoke::class => [],
6971
],
7072
];

src/Events/AppStore/Revoke.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
4+
namespace Imdhemy\Purchases\Events\AppStore;
5+
6+
use Imdhemy\Purchases\Events\PurchaseEvent;
7+
8+
class Revoke extends PurchaseEvent
9+
{
10+
}

tests/Events/AppStore/EventFactoryTest.php

+17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Imdhemy\AppStore\ServerNotifications\ServerNotification;
66
use Imdhemy\Purchases\Contracts\PurchaseEventContract;
77
use Imdhemy\Purchases\Events\AppStore\EventFactory;
8+
use Imdhemy\Purchases\Events\AppStore\Revoke;
89
use Imdhemy\Purchases\ServerNotifications\AppStoreServerNotification;
910
use PHPUnit\Framework\TestCase;
1011

@@ -22,4 +23,20 @@ public function test_create()
2223
$appStoreServerNotification = new AppStoreServerNotification($serverNotification);
2324
$this->assertInstanceOf(PurchaseEventContract::class, EventFactory::create($appStoreServerNotification));
2425
}
26+
27+
/**
28+
* @test
29+
*/
30+
public function test_it_creates_revoke_event()
31+
{
32+
$path = realpath(__DIR__ . '/../../appstore-server-notification.json');
33+
$serverNotificationBody = json_decode(file_get_contents($path), true);
34+
$serverNotificationBody['notification_type'] = ServerNotification::REVOKE;
35+
36+
$serverNotification = ServerNotification::fromArray($serverNotificationBody);
37+
$appStoreServerNotification = new AppStoreServerNotification($serverNotification);
38+
39+
$this->assertInstanceOf(PurchaseEventContract::class, EventFactory::create($appStoreServerNotification));
40+
$this->assertInstanceOf(Revoke::class, EventFactory::create($appStoreServerNotification));
41+
}
2542
}

0 commit comments

Comments
 (0)