$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
- new HashBagOStuff( [ 'maxKeys' => 100 ] )
+ $this->getMockCache()
);
$store->duplicateEntry(
$this->isType( 'string' )
);
+ $mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
- new HashBagOStuff( [ 'maxKeys' => 100 ] )
+ $mockCache
);
$store->duplicateEntry(
)
->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
+ $mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
- new HashBagOStuff( [ 'maxKeys' => 100 ] )
+ $mockCache
);
$store->duplicateAllAssociatedEntries(
$this->isType( 'string' )
);
+ $mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
- new HashBagOStuff( [ 'maxKeys' => 100 ] )
+ $mockCache
);
$store->duplicateAllAssociatedEntries(
->will( $this->returnValue( [] ) );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'delete' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->method( 'selectRow' );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'delete' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->will( $this->returnValue( 1 ) );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->once() )
->method( 'delete' )
->with( '0:SomeDbKey:1' );
->will( $this->returnValue( 0 ) );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->once() )
->method( 'delete' )
->with( '0:SomeDbKey:1' );
->method( 'delete' );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )
->method( 'delete' );
) );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->once() )
->method( 'get' )
->with(
$cachedItem = new WatchedItem( $mockUser, $linkTarget, '20151212010101' );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'delete' );
+ $mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->once() )
->method( 'get' )
->with(
'0:SomeDbKey:1'
)
->will( $this->returnValue( $cachedItem ) );
- $mockCache->expects( $this->never() )
- ->method( 'set' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->will( $this->returnValue( [] ) );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+ $mockCache->expects( $this->once() )
+ ->method( 'get' )
+ ->with( '0:SomeDbKey:1' )
+ ->will( $this->returnValue( false ) );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->method( 'selectRow' );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
) );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'delete' );
+ $mockCache->expects( $this->once() )
+ ->method( 'get' )
+ ->with( '0:SomeDbKey:1' )
+ ->will( $this->returnValue( false ) );
$mockCache->expects( $this->once() )
->method( 'set' )
->with(
->will( $this->returnValue( [] ) );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+ $mockCache->expects( $this->once() )
+ ->method( 'get' )
+ ->with( '0:SomeDbKey:1' )
+ ->will( $this->returnValue( false ) );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->method( 'selectRow' );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->method( 'selectRow' );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
->will( $this->returnValue( [] ) );
$mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )
- ->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
) );
$mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->once() )
->method( 'set' )
->with(
->method( 'selectRow' );
$mockCache = $this->getMockCache();
+ $mockDb->expects( $this->never() )
+ ->method( 'get' );
$mockDb->expects( $this->never() )
->method( 'set' );
$mockDb->expects( $this->never() )
->method( 'selectRow' );
$mockCache = $this->getMockCache();
+ $mockDb->expects( $this->never() )
+ ->method( 'get' );
$mockDb->expects( $this->never() )
->method( 'set' );
$mockDb->expects( $this->never() )
) );
$mockCache = $this->getMockCache();
+ $mockDb->expects( $this->never() )
+ ->method( 'get' );
$mockDb->expects( $this->never() )
->method( 'set' );
$mockDb->expects( $this->never() )
]
);
+ $mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
- new HashBagOStuff( [ 'maxKeys' => 100 ] )
+ $mockCache
);
$this->assertEquals(
$mockDb->expects( $this->never() )
->method( 'update' );
+ $mockCache = $this->getMockCache();
+ $mockCache->expects( $this->never() )->method( 'set' );
+ $mockCache->expects( $this->never() )->method( 'get' );
+ $mockCache->expects( $this->never() )->method( 'delete' );
+
$store = new WatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
- new HashBagOStuff( [ 'maxKeys' => 100 ] )
+ $mockCache
);
$watchers = $store->updateNotificationTimestamp(
$this->assertEmpty( $watchers );
}
+ public function testUpdateNotificationTimestamp_clearsCachedItems() {
+ $user = $this->getMockNonAnonUserWithId( 1 );
+ $titleValue = new TitleValue( 0, 'SomeDbKey' );
+
+ $mockDb = $this->getMockDb();
+ $mockDb->expects( $this->once() )
+ ->method( 'selectRow' )
+ ->will( $this->returnValue(
+ $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+ ) );
+ $mockDb->expects( $this->once() )
+ ->method( 'select' )
+ ->will(
+ $this->returnValue( [
+ $this->getFakeRow( [ 'wl_user' => '2' ] ),
+ $this->getFakeRow( [ 'wl_user' => '3' ] )
+ ] )
+ );
+ $mockDb->expects( $this->once() )
+ ->method( 'onTransactionIdle' )
+ ->with( $this->isType( 'callable' ) )
+ ->will( $this->returnCallback( function( $callable ) {
+ $callable();
+ } ) );
+ $mockDb->expects( $this->once() )
+ ->method( 'update' );
+
+ $mockCache = $this->getMockCache();
+ $mockCache->expects( $this->once() )
+ ->method( 'set' )
+ ->with( '0:SomeDbKey:1', $this->isType( 'object' ) );
+ $mockCache->expects( $this->once() )
+ ->method( 'get' )
+ ->with( '0:SomeDbKey:1' );
+ $mockCache->expects( $this->once() )
+ ->method( 'delete' )
+ ->with( '0:SomeDbKey:1' );
+
+ $store = new WatchedItemStore(
+ $this->getMockLoadBalancer( $mockDb ),
+ $mockCache
+ );
+
+ // This will add the item to the cache
+ $store->getWatchedItem( $user, $titleValue );
+
+ $store->updateNotificationTimestamp(
+ $this->getMockNonAnonUserWithId( 1 ),
+ $titleValue,
+ '20151212010101'
+ );
+ }
+
}