2020-05-22 22:02:34 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 00:38:27 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Push\NotificationRequestJob;
|
|
|
|
use MediaWiki\Extension\Notifications\Push\PushNotifier;
|
2023-12-11 15:33:08 +00:00
|
|
|
use MediaWiki\User\CentralId\CentralIdLookup;
|
|
|
|
use MediaWiki\User\User;
|
2020-05-22 22:02:34 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
2022-04-08 00:38:27 +00:00
|
|
|
/** @covers \MediaWiki\Extension\Notifications\Push\PushNotifier */
|
2020-05-22 22:02:34 +00:00
|
|
|
class PushNotifierTest extends MediaWikiIntegrationTestCase {
|
|
|
|
|
2020-06-17 19:59:42 +00:00
|
|
|
public function testCreateJob(): void {
|
2023-07-17 18:09:54 +00:00
|
|
|
$user = $this->createMock( User::class );
|
|
|
|
$centralId = 42;
|
|
|
|
$centralIdLookup = $this->createMock( CentralIdLookup::class );
|
|
|
|
$centralIdLookup->method( 'centralIdFromLocalUser' )
|
|
|
|
->with( $user )
|
|
|
|
->willReturn( 42 );
|
|
|
|
$this->setService( 'CentralIdLookup', $centralIdLookup );
|
2020-05-22 22:02:34 +00:00
|
|
|
$notifier = TestingAccessWrapper::newFromClass( PushNotifier::class );
|
2020-06-17 19:59:42 +00:00
|
|
|
$job = $notifier->createJob( $user );
|
2020-05-22 22:02:34 +00:00
|
|
|
$this->assertInstanceOf( NotificationRequestJob::class, $job );
|
|
|
|
$this->assertSame( 'EchoPushNotificationRequest', $job->getType() );
|
|
|
|
$this->assertSame( $centralId, $job->getParams()['centralId'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|