mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-15 02:03:53 +00:00
Use real user ID in EchoNotifierTest
Echo will at some point try to load the user with the given ID, and will throw an exception if it doesn't exist. The test is currently passing just because we're not properly cleaning DB tables, and the user with ID 1 happens to exist at that point, but it will fail with core change Ie2f1809d. Change-Id: Ie686f4d5c2842e45a6ed564b311bb5d9b0265091
This commit is contained in:
parent
33a5fec0ec
commit
a10765baec
|
@ -21,13 +21,13 @@ class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
|||
'2' => 42,
|
||||
];
|
||||
|
||||
private function getFilterLookup(): FilterLookup {
|
||||
private function getFilterLookup( int $userID = null ): FilterLookup {
|
||||
$lookup = $this->createMock( FilterLookup::class );
|
||||
$lookup->method( 'getFilter' )
|
||||
->willReturnCallback( function ( $filter, $global ) {
|
||||
->willReturnCallback( function ( $filter, $global ) use ( $userID ) {
|
||||
$userID ??= self::USER_IDS[ $global ? "global-$filter" : $filter ] ?? 0;
|
||||
$filterObj = $this->createMock( ExistingFilter::class );
|
||||
$filterObj->method( 'getUserID' )
|
||||
->willReturn( self::USER_IDS[ $global ? "global-$filter" : $filter ] ?? 0 );
|
||||
$filterObj->method( 'getUserID' )->willReturn( $userID );
|
||||
return $filterObj;
|
||||
} );
|
||||
return $lookup;
|
||||
|
@ -74,11 +74,11 @@ class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers ::notifyForFilter
|
||||
*/
|
||||
public function testNotifyForFilter() {
|
||||
if ( !class_exists( Event::class ) ) {
|
||||
$this->markTestSkipped( 'Echo not loaded' );
|
||||
}
|
||||
$this->markTestSkippedIfExtensionNotLoaded( 'Echo' );
|
||||
// Use a real user, or Echo will throw an exception.
|
||||
$user = $this->getTestUser()->getUserIdentity();
|
||||
$notifier = new EchoNotifier(
|
||||
$this->getFilterLookup(),
|
||||
$this->getFilterLookup( $user->getId() ),
|
||||
$this->createMock( ConsequencesRegistry::class ),
|
||||
true
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue