mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
Mock IDatabase instead of DatabaseMysqli
PHPUnit 4 on HHVM is unable to create a mock for a class that uses variadic arguments in one of its methods. Details at I0e027f5ec66 in core. To work around this, IDatabase will continue to document it the old-fashioned way so that Phan can analyse it correctly, and also so that PHPUnit can mock it properly. Change-Id: I4b8f2b8a8bb54b71d8b4836c3663f1a646ece1bd
This commit is contained in:
parent
0053181835
commit
1278c66673
|
@ -122,7 +122,7 @@ class MWEchoNotifUserTest extends MediaWikiTestCase {
|
|||
$gateway->expects( $this->any() )
|
||||
->method( 'getDB' )
|
||||
->will( $this->returnValue(
|
||||
$this->getMockBuilder( Database::class )
|
||||
$this->getMockBuilder( IDatabase::class )
|
||||
->disableOriginalConstructor()->getMock()
|
||||
) );
|
||||
|
||||
|
|
|
@ -106,9 +106,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiTestCase {
|
|||
'selectRow' => '',
|
||||
'selectRowCount' => '',
|
||||
];
|
||||
$db = $this->getMockBuilder( DatabaseMysqli::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$db = $this->getMock( IDatabase::class );
|
||||
$db->expects( $this->any() )
|
||||
->method( 'update' )
|
||||
->will( $this->returnValue( $dbResult['update'] ) );
|
||||
|
|
|
@ -103,9 +103,7 @@ class EchoEventMapperTest extends MediaWikiTestCase {
|
|||
'select' => '',
|
||||
'selectRow' => ''
|
||||
];
|
||||
$db = $this->getMockBuilder( DatabaseMysqli::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$db = $this->getMock( IDatabase::class );
|
||||
$db->expects( $this->any() )
|
||||
->method( 'insert' )
|
||||
->will( $this->returnValue( $dbResult['insert'] ) );
|
||||
|
|
|
@ -128,9 +128,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase {
|
|||
|
||||
public function testDeleteByUserEventOffset() {
|
||||
$this->setMwGlobals( [ 'wgUpdateRowsPerQuery' => 4 ] );
|
||||
$mockDb = $this->getMockBuilder( DatabaseMysqli::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mockDb = $this->getMock( IDatabase::class );
|
||||
$mockDb->expects( $this->any() )
|
||||
->method( 'selectFieldValues' )
|
||||
->will( $this->returnValue( [ 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 ] ) );
|
||||
|
@ -153,7 +151,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase {
|
|||
$this->anything()
|
||||
]
|
||||
)
|
||||
->will( $this->returnValue( true ) );
|
||||
->willReturn( true );
|
||||
|
||||
$notifMapper = new EchoNotificationMapper( $this->mockMWEchoDbFactory( $mockDb ) );
|
||||
$this->assertTrue( $notifMapper->deleteByUserEventOffset( User::newFromId( 1 ), 500 ) );
|
||||
|
@ -221,9 +219,7 @@ class EchoNotificationMapperTest extends MediaWikiTestCase {
|
|||
'delete' => ''
|
||||
];
|
||||
|
||||
$db = $this->getMockBuilder( DatabaseMysqli::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$db = $this->getMock( IDatabase::class );
|
||||
$db->expects( $this->any() )
|
||||
->method( 'insert' )
|
||||
->will( $this->returnValue( $dbResult['insert'] ) );
|
||||
|
|
|
@ -74,9 +74,7 @@ class EchoTargetPageMapperTest extends MediaWikiTestCase {
|
|||
'select' => '',
|
||||
'delete' => ''
|
||||
];
|
||||
$db = $this->getMockBuilder( DatabaseMysqli::class )
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$db = $this->getMock( IDatabase::class );
|
||||
$db->expects( $this->any() )
|
||||
->method( 'insert' )
|
||||
->will( $this->returnValue( $dbResult['insert'] ) );
|
||||
|
|
Loading…
Reference in a new issue