Merge "Ability to create tests with nested modules"
[lhc/web/wiklou.git] / tests / phpunit / includes / WatchedItemStoreUnitTest.php
index ba47059..f31028d 100644 (file)
@@ -13,7 +13,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
         * @return PHPUnit_Framework_MockObject_MockObject|IDatabase
         */
        private function getMockDb() {
-               return $this->getMock( IDatabase::class );
+               return $this->createMock( IDatabase::class );
        }
 
        /**
@@ -21,8 +21,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
         */
        private function getMockLoadBalancer(
                $mockDb,
-               $expectedConnectionType = null,
-               $readOnlyReason = false
+               $expectedConnectionType = null
        ) {
                $mock = $this->getMockBuilder( LoadBalancer::class )
                        ->disableOriginalConstructor()
@@ -37,9 +36,6 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                                ->method( 'getConnectionRef' )
                                ->will( $this->returnValue( $mockDb ) );
                }
-               $mock->expects( $this->any() )
-                       ->method( 'getReadOnlyReason' )
-                       ->will( $this->returnValue( $readOnlyReason ) );
                return $mock;
        }
 
@@ -58,12 +54,25 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                return $mock;
        }
 
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|ReadOnlyMode
+        */
+       private function getMockReadOnlyMode( $readOnly = false ) {
+               $mock = $this->getMockBuilder( ReadOnlyMode::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'isReadOnly' )
+                       ->will( $this->returnValue( $readOnly ) );
+               return $mock;
+       }
+
        /**
         * @param int $id
         * @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 ) );
@@ -88,10 +97,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                return $fakeRow;
        }
 
-       private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache ) {
+       private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache,
+               ReadOnlyMode $readOnlyMode
+       ) {
                return new WatchedItemStore(
                        $loadBalancer,
-                       $cache
+                       $cache,
+                       $readOnlyMode
                );
        }
 
@@ -118,7 +130,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals( 12, $store->countWatchedItems( $user ) );
@@ -148,7 +161,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals( 7, $store->countWatchers( $titleValue ) );
@@ -199,7 +213,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $expected = [
@@ -265,7 +280,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $expected = [
@@ -313,7 +329,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals( 7, $store->countVisitingWatchers( $titleValue, '111' ) );
@@ -392,7 +409,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $expected = [
@@ -494,7 +512,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $expected = [
@@ -547,7 +566,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $expected = [
@@ -584,7 +604,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals( 9, $store->countUnreadNotifications( $user ) );
@@ -618,7 +639,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertSame(
@@ -655,7 +677,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -685,7 +708,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache()
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
                );
 
                $store->duplicateEntry(
@@ -743,7 +767,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $store->duplicateEntry(
@@ -789,7 +814,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $store->duplicateAllAssociatedEntries(
@@ -882,7 +908,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $store->duplicateAllAssociatedEntries(
@@ -914,7 +941,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $store->addWatch(
@@ -934,7 +962,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $store->addWatch(
@@ -945,8 +974,9 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
        public function testAddWatchBatchForUser_readOnlyDBReturnsFalse() {
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb(), null, 'Some Reason' ),
-                       $this->getMockCache()
+                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode( true )
                );
 
                $this->assertFalse(
@@ -991,7 +1021,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $mockUser = $this->getMockNonAnonUserWithId( 1 );
@@ -1015,7 +1046,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1038,7 +1070,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertTrue(
@@ -1072,7 +1105,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $watchedItem = $store->loadWatchedItem(
@@ -1106,7 +1140,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1128,7 +1163,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1163,7 +1199,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertTrue(
@@ -1198,7 +1235,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1221,7 +1259,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1265,7 +1304,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $watchedItem = $store->getWatchedItem(
@@ -1299,7 +1339,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -1336,7 +1377,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1359,7 +1401,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1399,7 +1442,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
                $user = $this->getMockNonAnonUserWithId( 1 );
 
@@ -1449,7 +1493,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $mockLoadBalancer,
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $watchedItems = $store->getWatchedItemsForUser(
@@ -1462,7 +1507,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
        public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $this->getMockDb() ),
-                       $this->getMockCache()
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
                );
 
                $this->setExpectedException( 'InvalidArgumentException' );
@@ -1503,7 +1549,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertTrue(
@@ -1539,7 +1586,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1562,7 +1610,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1629,7 +1678,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -1679,7 +1729,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -1740,7 +1791,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -1780,7 +1832,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -1806,7 +1859,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -1830,7 +1884,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1863,7 +1918,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertFalse(
@@ -1908,7 +1964,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                // Note: This does not actually assert the job is correct
@@ -1948,7 +2005,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                // Note: This does not actually assert the job is correct
@@ -1978,7 +2036,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
         * @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 ) ) );
@@ -2041,7 +2099,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $callableCallCounter = 0;
@@ -2107,7 +2166,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $addUpdateCallCounter = 0;
@@ -2182,7 +2242,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $callableCallCounter = 0;
@@ -2248,7 +2309,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $addUpdateCallCounter = 0;
@@ -2325,7 +2387,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $addUpdateCallCounter = 0;
@@ -2370,7 +2433,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
        public function testSetNotificationTimestampsForUser_anonUser() {
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $this->getMockDb() ),
-                       $this->getMockCache()
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
                );
                $this->assertFalse( $store->setNotificationTimestampsForUser( $this->getAnonUser(), '' ) );
        }
@@ -2396,7 +2460,38 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache()
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->setNotificationTimestampsForUser( $user, $timestamp )
+               );
+       }
+
+       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->getMockReadOnlyMode()
                );
 
                $this->assertTrue(
@@ -2434,7 +2529,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache()
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertTrue(
@@ -2476,7 +2572,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $this->assertEquals(
@@ -2516,7 +2613,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                $watchers = $store->updateNotificationTimestamp(
@@ -2559,7 +2657,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
                $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
                );
 
                // This will add the item to the cache