mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Merge "tests: Return FakeResultWrapper from mocked IReadableDatabase::select"
This commit is contained in:
commit
03309bd42d
|
@ -3,6 +3,7 @@
|
|||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\Mapper\EventMapper;
|
||||
use MediaWiki\Extension\Notifications\Model\Event;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\InsertQueryBuilder;
|
||||
|
||||
|
@ -103,7 +104,7 @@ class EventMapperTest extends MediaWikiIntegrationTestCase {
|
|||
$dbResult += [
|
||||
'insert' => '',
|
||||
'insertId' => '',
|
||||
'select' => '',
|
||||
'select' => [],
|
||||
'selectRow' => ''
|
||||
];
|
||||
$db = $this->createMock( IDatabase::class );
|
||||
|
@ -112,7 +113,7 @@ class EventMapperTest extends MediaWikiIntegrationTestCase {
|
|||
$db->method( 'insertId' )
|
||||
->willReturn( $dbResult['insertId'] );
|
||||
$db->method( 'select' )
|
||||
->willReturn( $dbResult['select'] );
|
||||
->willReturn( new FakeResultWrapper( $dbResult['select'] ) );
|
||||
$db->method( 'selectRow' )
|
||||
->willReturn( $dbResult['selectRow'] );
|
||||
$db->method( 'newInsertQueryBuilder' )
|
||||
|
|
|
@ -5,6 +5,7 @@ use MediaWiki\Extension\Notifications\Mapper\NotificationMapper;
|
|||
use MediaWiki\Extension\Notifications\Model\Notification;
|
||||
use MediaWiki\User\User;
|
||||
use Wikimedia\Rdbms\DeleteQueryBuilder;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
/**
|
||||
|
@ -115,7 +116,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
|
|||
$this->setMwGlobals( [ 'wgUpdateRowsPerQuery' => 4 ] );
|
||||
$mockDb = $this->createMock( IDatabase::class );
|
||||
$makeResultRows = static function ( $eventIds ) {
|
||||
return new ArrayIterator( array_map( static function ( $eventId ) {
|
||||
return new FakeResultWrapper( array_map( static function ( $eventId ) {
|
||||
return (object)[ 'notification_event' => $eventId ];
|
||||
}, $eventIds ) );
|
||||
};
|
||||
|
@ -229,7 +230,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
|
|||
protected function mockDb( array $dbResult ) {
|
||||
$dbResult += [
|
||||
'insert' => '',
|
||||
'select' => '',
|
||||
'select' => [],
|
||||
'selectRow' => '',
|
||||
'delete' => ''
|
||||
];
|
||||
|
@ -238,7 +239,7 @@ class NotificationMapperTest extends MediaWikiIntegrationTestCase {
|
|||
$db->method( 'insert' )
|
||||
->willReturn( $dbResult['insert'] );
|
||||
$db->method( 'select' )
|
||||
->willReturn( $dbResult['select'] );
|
||||
->willReturn( new FakeResultWrapper( $dbResult['select'] ) );
|
||||
$db->method( 'delete' )
|
||||
->willReturn( $dbResult['delete'] );
|
||||
$db->method( 'selectRow' )
|
||||
|
|
|
@ -4,6 +4,7 @@ use MediaWiki\Config\HashConfig;
|
|||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\Gateway\UserNotificationGateway;
|
||||
use MediaWiki\User\User;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\UpdateQueryBuilder;
|
||||
|
||||
|
@ -144,9 +145,9 @@ class UserNotificationGatewayTest extends MediaWikiUnitTestCase {
|
|||
protected function mockDb( array $dbResult = [] ) {
|
||||
$dbResult += [
|
||||
'update' => '',
|
||||
'select' => '',
|
||||
'select' => [],
|
||||
'selectRow' => '',
|
||||
'selectRowCount' => '',
|
||||
'selectRowCount' => 0,
|
||||
];
|
||||
$db = $this->createMock( IDatabase::class );
|
||||
$db->method( 'affectedRows' )
|
||||
|
@ -154,7 +155,7 @@ class UserNotificationGatewayTest extends MediaWikiUnitTestCase {
|
|||
$db->method( 'update' )
|
||||
->willReturn( $dbResult['update'] );
|
||||
$db->method( 'select' )
|
||||
->willReturn( $dbResult['select'] );
|
||||
->willReturn( new FakeResultWrapper( $dbResult['select'] ) );
|
||||
$db->method( 'selectRow' )
|
||||
->willReturn( $dbResult['selectRow'] );
|
||||
$db->method( 'selectRowCount' )
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper;
|
||||
use MediaWiki\Extension\Notifications\Model\TargetPage;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\InsertQueryBuilder;
|
||||
|
||||
|
@ -73,7 +74,7 @@ class TargetPageMapperTest extends MediaWikiUnitTestCase {
|
|||
$dbResult += [
|
||||
'insert' => '',
|
||||
'insertId' => '',
|
||||
'select' => '',
|
||||
'select' => [],
|
||||
'delete' => ''
|
||||
];
|
||||
$db = $this->createMock( IDatabase::class );
|
||||
|
@ -82,7 +83,7 @@ class TargetPageMapperTest extends MediaWikiUnitTestCase {
|
|||
$db->method( 'insertId' )
|
||||
->willReturn( $dbResult['insertId'] );
|
||||
$db->method( 'select' )
|
||||
->willReturn( $dbResult['select'] );
|
||||
->willReturn( new FakeResultWrapper( $dbResult['select'] ) );
|
||||
$db->method( 'delete' )
|
||||
->willReturn( $dbResult['delete'] );
|
||||
$db->method( 'newInsertQueryBuilder' )
|
||||
|
|
Loading…
Reference in a new issue