From: addshore Date: Mon, 18 Apr 2016 11:25:54 +0000 (+0100) Subject: Test coverage WatchedItemStore::addWatchBatchForUser to 100% X-Git-Tag: 1.31.0-rc.0~7262^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=80f9cfd32ea4376a24cabb9419ce1423950a0413;p=lhc%2Fweb%2Fwiklou.git Test coverage WatchedItemStore::addWatchBatchForUser to 100% Change-Id: I6ff916519af87a40187d86149b0b72c2ab5a5f26 --- diff --git a/tests/phpunit/includes/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/WatchedItemStoreUnitTest.php index 414f3b6643..9b3e798d50 100644 --- a/tests/phpunit/includes/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/WatchedItemStoreUnitTest.php @@ -17,7 +17,11 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { /** * @return PHPUnit_Framework_MockObject_MockObject|LoadBalancer */ - private function getMockLoadBalancer( $mockDb, $expectedConnectionType = null ) { + private function getMockLoadBalancer( + $mockDb, + $expectedConnectionType = null, + $readOnlyReason = false + ) { $mock = $this->getMockBuilder( LoadBalancer::class ) ->disableOriginalConstructor() ->getMock(); @@ -33,7 +37,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { } $mock->expects( $this->any() ) ->method( 'getReadOnlyReason' ) - ->will( $this->returnValue( false ) ); + ->will( $this->returnValue( $readOnlyReason ) ); return $mock; } @@ -941,6 +945,20 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase { ); } + public function testAddWatchBatchForUser_readOnlyDBReturnsFalse() { + $store = $this->newWatchedItemStore( + $this->getMockLoadBalancer( $this->getMockDb(), null, 'Some Reason' ), + $this->getMockCache() + ); + + $this->assertFalse( + $store->addWatchBatchForUser( + $this->getMockNonAnonUserWithId( 1 ), + [ new TitleValue( 0, 'Some_Page' ), new TitleValue( 1, 'Some_Page' ) ] + ) + ); + } + public function testAddWatchBatchForUser_nonAnonymousUser() { $mockDb = $this->getMockDb(); $mockDb->expects( $this->once() )