* @return PHPUnit_Framework_MockObject_MockObject|IDatabase
*/
private function getMockDb() {
- return $this->getMock( IDatabase::class );
+ return $this->createMock( IDatabase::class );
}
/**
* @return PHPUnit_Framework_MockObject_MockObject|User
*/
private function getMockNonAnonUserWithId( $id ) {
- $mock = $this->getMock( User::class );
+ $mock = $this->createMock( User::class );
$mock->expects( $this->any() )
->method( 'isAnon' )
->will( $this->returnValue( false ) );
* @return PHPUnit_Framework_MockObject_MockObject|Title
*/
private function getMockTitle( $text, $ns = 0 ) {
- $title = $this->getMock( Title::class );
+ $title = $this->createMock( Title::class );
$title->expects( $this->any() )
->method( 'getText' )
->will( $this->returnValue( str_replace( '_', ' ', $text ) ) );
);
}
+ public function testSetNotificationTimestampsForUser_nullTimestamp() {
+ $user = $this->getMockNonAnonUserWithId( 1 );
+ $timestamp = null;
+
+ $mockDb = $this->getMockDb();
+ $mockDb->expects( $this->once() )
+ ->method( 'update' )
+ ->with(
+ 'watchlist',
+ [ 'wl_notificationtimestamp' => null ],
+ [ 'wl_user' => 1 ]
+ )
+ ->will( $this->returnValue( true ) );
+ $mockDb->expects( $this->exactly( 0 ) )
+ ->method( 'timestamp' )
+ ->will( $this->returnCallback( function( $value ) {
+ return 'TS' . $value . 'TS';
+ } ) );
+
+ $store = $this->newWatchedItemStore(
+ $this->getMockLoadBalancer( $mockDb ),
+ $this->getMockCache()
+ );
+
+ $this->assertTrue(
+ $store->setNotificationTimestampsForUser( $user, $timestamp )
+ );
+ }
+
public function testSetNotificationTimestampsForUser_specificTargets() {
$user = $this->getMockNonAnonUserWithId( 1 );
$timestamp = '20100101010101';