X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fwatcheditem%2FWatchedItemStoreUnitTest.php;h=8ef8cb00d57cb917e86a3197378ee176afc79c1a;hp=52e653cb4c62017e942d895c9c6b61fc358656b6;hb=6f3d5a5204770b7e9076ec0c956631c32a9e1114;hpb=6f7e982df6479e27c3b17f2deda8404ef55f50e6 diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php index 52e653cb4c..8ef8cb00d5 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php @@ -47,6 +47,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { private function getMockCache() { $mock = $this->getMockBuilder( HashBagOStuff::class ) ->disableOriginalConstructor() + ->setMethods( [ 'get', 'set', 'delete', 'makeKey' ] ) ->getMock(); $mock->expects( $this->any() ) ->method( 'makeKey' ) @@ -443,7 +444,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ) ->will( $this->returnCallback( function ( $a, $conj ) { $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR '; - return join( $sqlConj, array_map( function ( $s ) { + return implode( $sqlConj, array_map( function ( $s ) { return '(' . $s . ')'; }, $a ) ); @@ -460,7 +461,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" . '))))' . ') OR ((wl_namespace = 1) AND (' . - "(((wl_title = 'AnotherDbKey') AND (". + "(((wl_title = 'AnotherDbKey') AND (" . "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" . ')))))'; $mockDb->expects( $this->once() ) @@ -540,7 +541,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ) ->will( $this->returnCallback( function ( $a, $conj ) { $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR '; - return join( $sqlConj, array_map( function ( $s ) { + return implode( $sqlConj, array_map( function ( $s ) { return '(' . $s . ')'; }, $a ) ); @@ -563,7 +564,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" . '))))' . ') OR ((wl_namespace = 1) AND (' . - "(((wl_title = 'AnotherDbKey') AND (". + "(((wl_title = 'AnotherDbKey') AND (" . "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" . '))))' . ') OR ' . @@ -2074,12 +2075,11 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->method( 'selectRow' ); $mockCache = $this->getMockCache(); - $mockDb->expects( $this->never() ) - ->method( 'get' ); - $mockDb->expects( $this->never() ) - ->method( 'set' ); - $mockDb->expects( $this->never() ) - ->method( 'delete' ); + $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->never() )->method( 'set' ); + $mockCache->expects( $this->once() ) + ->method( 'delete' ) + ->with( '0:SomeDbKey:1' ); $store = $this->newWatchedItemStore( $this->getMockLoadBalancer( $mockDb ), @@ -2168,12 +2168,11 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->method( 'selectRow' ); $mockCache = $this->getMockCache(); - $mockDb->expects( $this->never() ) - ->method( 'get' ); - $mockDb->expects( $this->never() ) - ->method( 'set' ); - $mockDb->expects( $this->never() ) - ->method( 'delete' ); + $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->never() )->method( 'set' ); + $mockCache->expects( $this->once() ) + ->method( 'delete' ) + ->with( '0:SomeTitle:1' ); $store = $this->newWatchedItemStore( $this->getMockLoadBalancer( $mockDb ), @@ -2235,12 +2234,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ) ); $mockCache = $this->getMockCache(); - $mockDb->expects( $this->never() ) - ->method( 'get' ); - $mockDb->expects( $this->never() ) - ->method( 'set' ); - $mockDb->expects( $this->never() ) - ->method( 'delete' ); + $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->once() ) + ->method( 'set' ) + ->with( '0:SomeDbKey:1', $this->isType( 'object' ) ); + $mockCache->expects( $this->once() ) + ->method( 'delete' ) + ->with( '0:SomeDbKey:1' ); $store = $this->newWatchedItemStore( $this->getMockLoadBalancer( $mockDb ), @@ -2311,12 +2311,11 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->will( $this->returnValue( false ) ); $mockCache = $this->getMockCache(); - $mockDb->expects( $this->never() ) - ->method( 'get' ); - $mockDb->expects( $this->never() ) - ->method( 'set' ); - $mockDb->expects( $this->never() ) - ->method( 'delete' ); + $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->never() )->method( 'set' ); + $mockCache->expects( $this->once() ) + ->method( 'delete' ) + ->with( '0:SomeDbKey:1' ); $store = $this->newWatchedItemStore( $this->getMockLoadBalancer( $mockDb ), @@ -2378,12 +2377,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ) ); $mockCache = $this->getMockCache(); - $mockDb->expects( $this->never() ) - ->method( 'get' ); - $mockDb->expects( $this->never() ) - ->method( 'set' ); - $mockDb->expects( $this->never() ) - ->method( 'delete' ); + $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->once() ) + ->method( 'set' ) + ->with( '0:SomeDbKey:1', $this->isType( 'object' ) ); + $mockCache->expects( $this->once() ) + ->method( 'delete' ) + ->with( '0:SomeDbKey:1' ); $store = $this->newWatchedItemStore( $this->getMockLoadBalancer( $mockDb ), @@ -2456,12 +2456,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ) ); $mockCache = $this->getMockCache(); - $mockDb->expects( $this->never() ) - ->method( 'get' ); - $mockDb->expects( $this->never() ) - ->method( 'set' ); - $mockDb->expects( $this->never() ) - ->method( 'delete' ); + $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->once() ) + ->method( 'set' ) + ->with( '0:SomeDbKey:1', $this->isType( 'object' ) ); + $mockCache->expects( $this->once() ) + ->method( 'delete' ) + ->with( '0:SomeDbKey:1' ); $store = $this->newWatchedItemStore( $this->getMockLoadBalancer( $mockDb ),