mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-11 15:38:37 +00:00
c71d826ede
Deprecated in T342301 in v1.41. This is now tracked automatically. The variable can be safely deleted. Change-Id: I3864ee85e8b0ff74385eee88018a37f61927f5ef
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Notifications\Push\Utils;
|
|
use MediaWiki\Extension\Notifications\Services;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @group Database
|
|
* @covers \MediaWiki\Extension\Notifications\Push\SubscriptionManager
|
|
*/
|
|
class SubscriptionManagerTest extends MediaWikiIntegrationTestCase {
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->setMwGlobals( 'wgEchoPushMaxSubscriptionsPerUser', 1 );
|
|
}
|
|
|
|
public function testManagePushSubscriptions(): void {
|
|
$subscriptionManagerBase = Services::getInstance()->getPushSubscriptionManager();
|
|
$subscriptionManager = TestingAccessWrapper::newFromObject( $subscriptionManagerBase );
|
|
|
|
$user = $this->getTestUser()->getUser();
|
|
$centralId = Utils::getPushUserId( $user );
|
|
|
|
$subscriptionManager->create( 'test', 'ABC123', $centralId );
|
|
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
|
|
$this->assertCount( 1, $subscriptions );
|
|
|
|
$subscriptionManager->delete( [ 'ABC123' ], $centralId );
|
|
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
|
|
$this->assertCount( 0, $subscriptions );
|
|
|
|
$subscriptionManager->create( 'test', 'ABC123', $centralId );
|
|
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
|
|
$this->assertCount( 1, $subscriptions );
|
|
|
|
$subscriptionManager->create( 'test', 'DEF456', $centralId );
|
|
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
|
|
$this->assertCount( 1, $subscriptions );
|
|
$this->assertEquals( 'DEF456', $subscriptions[0]->getToken() );
|
|
}
|
|
|
|
}
|