Change-Id: Ic3e1d23b8f707ae5e3221d1c2fd08878ae8bfff9
+ private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache ) {
+ return new WatchedItemStore(
+ $loadBalancer,
+ $cache
+ );
+ }
+
public function testGetDefaultInstance() {
$instanceOne = WatchedItemStore::getDefaultInstance();
$instanceTwo = WatchedItemStore::getDefaultInstance();
public function testGetDefaultInstance() {
$instanceOne = WatchedItemStore::getDefaultInstance();
$instanceTwo = WatchedItemStore::getDefaultInstance();
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
)
->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
)
->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$this->getMockCache()
);
$this->getMockLoadBalancer( $mockDb ),
$this->getMockCache()
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->method( 'delete' )
->with( '0:Some_Page:1' );
->method( 'delete' )
->with( '0:Some_Page:1' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )
->method( 'delete' );
$mockCache->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->method( 'delete' )
->with( '1:Some_Page:1' );
->method( 'delete' )
->with( '1:Some_Page:1' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )
->method( 'delete' );
$mockCache->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )
->method( 'delete' );
$mockCache->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->method( 'delete' )
->with( '0:SomeDbKey:1' );
->method( 'delete' )
->with( '0:SomeDbKey:1' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->method( 'delete' )
->with( '0:SomeDbKey:1' );
->method( 'delete' )
->with( '0:SomeDbKey:1' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )
->method( 'delete' );
$mockCache->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
)
->will( $this->returnValue( $cachedItem ) );
)
->will( $this->returnValue( $cachedItem ) );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->with( '0:SomeDbKey:1' )
->will( $this->returnValue( false ) );
->with( '0:SomeDbKey:1' )
->will( $this->returnValue( false ) );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'set' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
)
->will( $this->returnValue( [] ) );
)
->will( $this->returnValue( [] ) );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$mockLoadBalancer,
$mockCache
);
$mockLoadBalancer,
$mockCache
);
}
public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
}
public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $this->getMockDb() ),
$this->getMockCache()
);
$this->getMockLoadBalancer( $this->getMockDb() ),
$this->getMockCache()
);
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->with( '0:SomeDbKey:1' )
->will( $this->returnValue( false ) );
->with( '0:SomeDbKey:1' )
->will( $this->returnValue( false ) );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache = $this->getMockCache();
$mockCache->expects( $this->never() )->method( $this->anything() );
$mockCache = $this->getMockCache();
$mockCache->expects( $this->never() )->method( $this->anything() );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'set' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->method( 'delete' )
->with( '0:SomeDbKey:1' );
->method( 'delete' )
->with( '0:SomeDbKey:1' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockDb->expects( $this->never() )
->method( 'delete' );
$mockDb->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockDb->expects( $this->never() )
->method( 'delete' );
$mockDb->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockDb->expects( $this->never() )
->method( 'delete' );
$mockDb->expects( $this->never() )
->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
$mockCache->expects( $this->never() )->method( 'get' );
$mockCache->expects( $this->never() )->method( 'delete' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
->method( 'delete' )
->with( '0:SomeDbKey:1' );
->method( 'delete' )
->with( '0:SomeDbKey:1' );
- $store = new WatchedItemStore(
+ $store = $this->newWatchedItemStore(
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);
$this->getMockLoadBalancer( $mockDb ),
$mockCache
);