mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Avoid DB access in tests when possible
Use mocks where that makes sense, and add `@group Database` otherwise. Change-Id: I8f8ec8f4b2c73066cc8e7a6f8e38b3fc286a1070
This commit is contained in:
parent
b3c74b1412
commit
0d8422a569
|
@ -2,16 +2,20 @@
|
|||
|
||||
use MediaWiki\Extension\Notifications\Push\NotificationRequestJob;
|
||||
use MediaWiki\Extension\Notifications\Push\PushNotifier;
|
||||
use MediaWiki\Extension\Notifications\Push\Utils;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/** @covers \MediaWiki\Extension\Notifications\Push\PushNotifier */
|
||||
class PushNotifierTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
public function testCreateJob(): void {
|
||||
$user = $this->createMock( User::class );
|
||||
$centralId = 42;
|
||||
$centralIdLookup = $this->createMock( CentralIdLookup::class );
|
||||
$centralIdLookup->method( 'centralIdFromLocalUser' )
|
||||
->with( $user )
|
||||
->willReturn( 42 );
|
||||
$this->setService( 'CentralIdLookup', $centralIdLookup );
|
||||
$notifier = TestingAccessWrapper::newFromClass( PushNotifier::class );
|
||||
$user = $this->getTestUser()->getUser();
|
||||
$centralId = Utils::getPushUserId( $user );
|
||||
$job = $notifier->createJob( $user );
|
||||
$this->assertInstanceOf( NotificationRequestJob::class, $job );
|
||||
$this->assertSame( 'EchoPushNotificationRequest', $job->getType() );
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
use MediaWiki\Extension\Notifications\Push\Utils;
|
||||
|
||||
/** @covers \MediaWiki\Extension\Notifications\Push\Utils */
|
||||
/**
|
||||
* @covers \MediaWiki\Extension\Notifications\Push\Utils
|
||||
* @group Database
|
||||
*/
|
||||
class UtilsTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
public function testGetLoggedInPushId(): void {
|
||||
|
|
Loading…
Reference in a new issue