diff options
Diffstat (limited to 'Echo/tests/phpunit/api/Push/ApiEchoPushSubscriptionsDeleteTest.php')
-rw-r--r-- | Echo/tests/phpunit/api/Push/ApiEchoPushSubscriptionsDeleteTest.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Echo/tests/phpunit/api/Push/ApiEchoPushSubscriptionsDeleteTest.php b/Echo/tests/phpunit/api/Push/ApiEchoPushSubscriptionsDeleteTest.php new file mode 100644 index 00000000..f2ec0d66 --- /dev/null +++ b/Echo/tests/phpunit/api/Push/ApiEchoPushSubscriptionsDeleteTest.php @@ -0,0 +1,48 @@ +<?php + +/** + * @group medium + * @group API + * @group Database + * @covers \EchoPush\Api\ApiEchoPushSubscriptionsDelete + */ +class ApiEchoPushSubscriptionsDeleteTest extends ApiTestCase { + + /** @var User */ + private $user; + + public function setUp(): void { + parent::setUp(); + $this->setMwGlobals( 'wgEchoEnablePush', true ); + $this->tablesUsed[] = 'echo_push_subscription'; + $this->tablesUsed[] = 'echo_push_provider'; + $this->user = $this->getTestUser()->getUser(); + $this->createTestData(); + } + + public function testApiDeleteSubscription(): void { + $params = [ + 'action' => 'echopushsubscriptions', + 'command' => 'delete', + 'providertoken' => 'XYZ789', + ]; + $result = $this->doApiRequestWithToken( $params, null, $this->user ); + $this->assertEquals( 'Success', $result[0]['delete']['result'] ); + } + + public function testApiDeleteSubscriptionNotFound(): void { + $params = [ + 'action' => 'echopushsubscriptions', + 'command' => 'delete', + 'providertoken' => 'ABC123', + ]; + $this->expectException( ApiUsageException::class ); + $this->doApiRequestWithToken( $params, null, $this->user ); + } + + private function createTestData(): void { + $subscriptionManager = EchoServices::getInstance()->getPushSubscriptionManager(); + $subscriptionManager->create( $this->user, 'fcm', 'XYZ789' ); + } + +} |