Merge "Show protection log on creation-protected pages"
[lhc/web/wiklou.git] / tests / phpunit / includes / WatchedItemQueryServiceUnitTest.php
index bdec0a5..958d70a 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\TestingAccessWrapper;
+
 /**
  * @covers WatchedItemQueryService
  */
@@ -19,9 +21,9 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
                                $this->isType( 'array' ),
                                $this->isType( 'int' )
                        )
-                       ->will( $this->returnCallback( function( $a, $conj ) {
+                       ->will( $this->returnCallback( function ( $a, $conj ) {
                                $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
-                               return join( $sqlConj, array_map( function( $s ) {
+                               return join( $sqlConj, array_map( function ( $s ) {
                                        return '(' . $s . ')';
                                }, $a
                                ) );
@@ -29,7 +31,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
 
                $mock->expects( $this->any() )
                        ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function( $value ) {
+                       ->will( $this->returnCallback( function ( $value ) {
                                return "'$value'";
                        } ) );
 
@@ -39,7 +41,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
 
                $mock->expects( $this->any() )
                        ->method( 'bitAnd' )
-                       ->willReturnCallback( function( $a, $b ) {
+                       ->willReturnCallback( function ( $a, $b ) {
                                return "($a & $b)";
                        } );
 
@@ -56,7 +58,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
                        ->getMock();
                $mock->expects( $this->any() )
                        ->method( 'getConnectionRef' )
-                       ->with( DB_SLAVE )
+                       ->with( DB_REPLICA )
                        ->will( $this->returnValue( $mockDb ) );
                return $mock;
        }
@@ -66,7 +68,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
         * @return PHPUnit_Framework_MockObject_MockObject|User
         */
        private function getMockNonAnonUserWithId( $id ) {
-               $mock = $this->getMock( User::class );
+               $mock = $this->getMockBuilder( User::class )->getMock();
                $mock->expects( $this->any() )
                        ->method( 'isAnon' )
                        ->will( $this->returnValue( false ) );
@@ -104,12 +106,12 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
 
                $mock->expects( $this->any() )
                        ->method( 'isAllowed' )
-                       ->will( $this->returnCallback( function( $action ) use ( $notAllowedAction ) {
+                       ->will( $this->returnCallback( function ( $action ) use ( $notAllowedAction ) {
                                return $action !== $notAllowedAction;
                        } ) );
                $mock->expects( $this->any() )
                        ->method( 'isAllowedAny' )
-                       ->will( $this->returnCallback( function() use ( $notAllowedAction ) {
+                       ->will( $this->returnCallback( function () use ( $notAllowedAction ) {
                                $actions = func_get_args();
                                return !in_array( $notAllowedAction, $actions );
                        } ) );
@@ -142,7 +144,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
        }
 
        private function getMockAnonUser() {
-               $mock = $this->getMock( User::class );
+               $mock = $this->getMockBuilder( User::class )->getMock();
                $mock->expects( $this->any() )
                        ->method( 'isAnon' )
                        ->will( $this->returnValue( true ) );
@@ -1448,7 +1450,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
                $mockDb = $this->getMockDb();
                $mockDb->expects( $this->any() )
                        ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function( $value ) {
+                       ->will( $this->returnCallback( function ( $value ) {
                                return "'$value'";
                        } ) );
                $mockDb->expects( $this->any() )
@@ -1457,9 +1459,9 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
                                $this->isType( 'array' ),
                                $this->isType( 'int' )
                        )
-                       ->will( $this->returnCallback( function( $a, $conj ) {
+                       ->will( $this->returnCallback( function ( $a, $conj ) {
                                $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
-                               return join( $sqlConj, array_map( function( $s ) {
+                               return join( $sqlConj, array_map( function ( $s ) {
                                        return '(' . $s . ')';
                                }, $a
                                ) );