mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
15d48278be
Creates a EchoPushMaxSubscriptionsPerUser config setting (default: 0) that controls the maximum number of subscriptions a user may associate with the user's central user ID. The setting is enforced in EchoPush\SubscriptionManager::create(). To allow creating push subscriptions for development, set $wgEchoPushMaxSubscriptionsPerUser to a positive integer value in LocalSettings.php: $wgEchoPushMaxSubscriptionsPerUser = 10; Bug: T259150 Change-Id: Ib97b6b6cbb8161dd75dad92c54b4fe4fff80c421
37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @group Database
|
|
* @covers \EchoPush\SubscriptionManager
|
|
*/
|
|
class SubscriptionManagerTest extends MediaWikiIntegrationTestCase {
|
|
|
|
public function setUp(): void {
|
|
parent::setUp();
|
|
$this->tablesUsed[] = 'echo_push_subscription';
|
|
$this->tablesUsed[] = 'echo_push_provider';
|
|
$this->setMwGlobals( 'wgEchoPushMaxSubscriptionsPerUser', 1 );
|
|
}
|
|
|
|
public function testManagePushSubscriptions(): void {
|
|
$subscriptionManagerBase = EchoServices::getInstance()->getPushSubscriptionManager();
|
|
$subscriptionManager = TestingAccessWrapper::newFromObject( $subscriptionManagerBase );
|
|
|
|
$user = $this->getTestUser()->getUser();
|
|
$centralId = CentralIdLookup::factory()->centralIdFromLocalUser( $user );
|
|
|
|
$subscriptionManager->create( $user, 'test', 'ABC123' );
|
|
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
|
|
$this->assertCount( 1, $subscriptions );
|
|
$this->assertTrue( $subscriptionManager->userHasMaxAllowedSubscriptions( $centralId ) );
|
|
|
|
$subscriptionManager->delete( $user, 'ABC123' );
|
|
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
|
|
$this->assertCount( 0, $subscriptions );
|
|
$this->assertFalse( $subscriptionManager->userHasMaxAllowedSubscriptions( $centralId ) );
|
|
}
|
|
|
|
}
|