Mwjames has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/94101


Change subject: Tweak some test settings
......................................................................

Tweak some test settings

Change-Id: Iaf0dd9d9d29916606ed2fb11d495f81c9f06229a
---
M includes/Setup.php
M tests/phpunit/includes/RecurringEventsTest.php
M tests/phpunit/includes/SetupTest.php
M tests/phpunit/includes/hooks/FunctionHookDBIntegrationTest.php
M tests/phpunit/includes/storage/sqlstore/StatisticsCollectorTest.php
M tests/phpunit/mocks/MockObjectRepository.php
6 files changed, 167 insertions(+), 202 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki 
refs/changes/01/94101/1

diff --git a/includes/Setup.php b/includes/Setup.php
index 65c214a..c0b0483 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -36,42 +36,23 @@
        }
 
        /**
-        * Initialisation of the extension
-        *
         * @since 1.9
         */
        public function run() {
                Profiler::In();
 
                $this->init();
-
                $this->loadSettings();
 
-               // Register messages files
-               $this->registerMessageFiles();
-
-               // Register Api modules
-               $this->registerApiModules();
-
-               // Register Job classes
+               $this->registerI18n();
+               $this->registerWebApi();
                $this->registerJobClasses();
-
-               // Register Special pages
                $this->registerSpecialPages();
+               $this->registerPermissions();
 
-               // Rights and groups
-               $this->registerRights();
-
-               // ParamDefinitions
                $this->registerParamDefinitions();
-
-               //FooterIcons
                $this->registerFooterIcon();
-
-               // Register hooks (needs to be loaded after settings are 
initialized)
                $this->registerFunctionHooks();
-
-               // Register parser hooks
                $this->registerParserHooks();
 
                Profiler::Out();
@@ -115,8 +96,6 @@
        }
 
        /**
-        * Register settings
-        *
         * @since 1.9
         */
        protected function registerSettings( Settings $settings ) {
@@ -125,11 +104,11 @@
        }
 
        /**
-        * Register messages files
+        * @see https://www.mediawiki.org/wiki/Manual:$wgExtensionMessagesFiles
         *
         * @since 1.9
         */
-       protected function registerMessageFiles() {
+       protected function registerI18n() {
 
                $smwgIP = $this->settings->get( 'smwgIP' );
 
@@ -140,15 +119,11 @@
        }
 
        /**
-        * Register Api modules
-        *
-        * @note Associative array mapping module name to class name
-        *
         * @see https://www.mediawiki.org/wiki/Manual:$wgAPIModules
         *
         * @since 1.9
         */
-       protected function registerApiModules() {
+       protected function registerWebApi() {
 
                $this->globals['wgAPIModules']['smwinfo'] = '\SMW\Api\Info';
                $this->globals['wgAPIModules']['ask']     = '\SMW\Api\Ask';
@@ -158,29 +133,25 @@
        }
 
        /**
-        * Register Job classes to their handling classes
-        *
         * @see https://www.mediawiki.org/wiki/Manual:$wgJobClasses
         *
         * @since 1.9
         */
        protected function registerJobClasses() {
 
-               $this->globals['wgJobClasses']['SMW\UpdateJob']           = 
'SMW\UpdateJob';
-               $this->globals['wgJobClasses']['SMW\RefreshJob']          = 
'SMW\RefreshJob';
+               $this->globals['wgJobClasses']['SMW\UpdateJob']  = 
'SMW\UpdateJob';
+               $this->globals['wgJobClasses']['SMW\RefreshJob'] = 
'SMW\RefreshJob';
                $this->globals['wgJobClasses']['SMW\UpdateDispatcherJob'] = 
'SMW\UpdateDispatcherJob';
 
        }
 
        /**
-        * Register rights and groups
-        *
         * @see https://www.mediawiki.org/wiki/Manual:$wgAvailableRights
         * @see https://www.mediawiki.org/wiki/Manual:$wgGroupPermissions
         *
         * @since 1.9
         */
-       protected function registerRights() {
+       protected function registerPermissions() {
 
                // Rights
                $this->globals['wgAvailableRights'][] = 'smw-admin';
@@ -192,8 +163,6 @@
        }
 
        /**
-        * Register special pages
-        *
         * @see https://www.mediawiki.org/wiki/Manual:$wgSpecialPages
         *
         * @since 1.9
@@ -266,8 +235,6 @@
        }
 
        /**
-        * Register
-        *
         * @since 1.9
         */
        protected function registerParamDefinitions() {
@@ -283,8 +250,6 @@
        }
 
        /**
-        * Register poweredby footer icon
-        *
         * @see https://www.mediawiki.org/wiki/Manual:$wgFooterIcons
         *
         * @since 1.9
@@ -299,12 +264,10 @@
        }
 
        /**
-        * Register function hooks
+        * @see https://www.mediawiki.org/wiki/Manual:$this->globals['wgHooks']
         *
         * @note $this->globals['wgHooks'] contains a list of hooks which 
specifies for every event an
         * array of functions to be called.
-        *
-        * @see https://www.mediawiki.org/wiki/Manual:$this->globals['wgHooks']
         *
         * @since 1.9
         */
@@ -312,7 +275,7 @@
 
                $globals  = $this->globals;
                $context  = $this->withContext();
-               $registry = $context->getDependencyBuilder()->newObject( 
'FunctionHookRegistry' );
+               $functionHook = $context->getDependencyBuilder()->newObject( 
'FunctionHookRegistry' );
 
                /**
                 * Hook: Called by BaseTemplate when building the toolbox array 
and
@@ -322,8 +285,8 @@
                 *
                 * @since  1.9
                 */
-               $this->globals['wgHooks']['BaseTemplateToolbox'][] = function ( 
$skinTemplate, &$toolbox ) use ( $registry ) {
-                       return $registry->register( new BaseTemplateToolbox( 
$skinTemplate, $toolbox ) )->process();
+               $this->globals['wgHooks']['BaseTemplateToolbox'][] = function ( 
$skinTemplate, &$toolbox ) use ( $functionHook ) {
+                       return $functionHook->register( new 
BaseTemplateToolbox( $skinTemplate, $toolbox ) )->process();
                };
 
                /**
@@ -334,8 +297,8 @@
                 *
                 * @since  1.9
                 */
-               $this->globals['wgHooks']['SkinAfterContent'][] = function ( 
&$data, $skin = null ) use ( $registry ) {
-                       return $registry->register( new SkinAfterContent( 
$data, $skin ) )->process();
+               $this->globals['wgHooks']['SkinAfterContent'][] = function ( 
&$data, $skin = null ) use ( $functionHook ) {
+                       return $functionHook->register( new SkinAfterContent( 
$data, $skin ) )->process();
                };
 
                /**
@@ -345,8 +308,8 @@
                 *
                 * @since  1.9
                 */
-               $this->globals['wgHooks']['OutputPageParserOutput'][] = 
function ( &$outputPage, $parserOutput ) use ( $registry ) {
-                       return $registry->register( new OutputPageParserOutput( 
$outputPage, $parserOutput ) )->process();
+               $this->globals['wgHooks']['OutputPageParserOutput'][] = 
function ( &$outputPage, $parserOutput ) use ( $functionHook ) {
+                       return $functionHook->register( new 
OutputPageParserOutput( $outputPage, $parserOutput ) )->process();
                };
 
                /**
@@ -356,8 +319,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['BeforePageDisplay'][] = function ( 
&$outputPage, &$skin ) use ( $registry ) {
-                       return $registry->register( new BeforePageDisplay( 
$outputPage, $skin ) )->process();
+               $this->globals['wgHooks']['BeforePageDisplay'][] = function ( 
&$outputPage, &$skin ) use ( $functionHook ) {
+                       return $functionHook->register( new BeforePageDisplay( 
$outputPage, $skin ) )->process();
                };
 
                /**
@@ -368,8 +331,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['InternalParseBeforeLinks'][] = 
function ( &$parser, &$text ) use ( $registry ) {
-                       return $registry->register( new 
InternalParseBeforeLinks( $parser, $text ) )->process();
+               $this->globals['wgHooks']['InternalParseBeforeLinks'][] = 
function ( &$parser, &$text ) use ( $functionHook ) {
+                       return $functionHook->register( new 
InternalParseBeforeLinks( $parser, $text ) )->process();
                };
 
                /**
@@ -380,8 +343,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['NewRevisionFromEditComplete'][] = 
function ( $wikiPage, $revision, $baseId, $user ) use ( $registry ) {
-                       return $registry->register( new 
NewRevisionFromEditComplete( $wikiPage, $revision, $baseId, $user ) 
)->process();
+               $this->globals['wgHooks']['NewRevisionFromEditComplete'][] = 
function ( $wikiPage, $revision, $baseId, $user ) use ( $functionHook ) {
+                       return $functionHook->register( new 
NewRevisionFromEditComplete( $wikiPage, $revision, $baseId, $user ) 
)->process();
                };
 
                /**
@@ -392,8 +355,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['TitleMoveComplete'][] = function ( 
&$oldTitle, &$newTitle, &$user, $oldId, $newId ) use ( $registry ) {
-                       return $registry->register( new TitleMoveComplete( 
$oldTitle, $newTitle, $user, $oldId, $newId ) )->process();
+               $this->globals['wgHooks']['TitleMoveComplete'][] = function ( 
&$oldTitle, &$newTitle, &$user, $oldId, $newId ) use ( $functionHook ) {
+                       return $functionHook->register( new TitleMoveComplete( 
$oldTitle, $newTitle, $user, $oldId, $newId ) )->process();
                };
 
                /**
@@ -403,8 +366,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['ArticlePurge'][] = function ( 
&$wikiPage ) use ( $registry ) {
-                       return $registry->register( new ArticlePurge( $wikiPage 
) )->process();
+               $this->globals['wgHooks']['ArticlePurge'][] = function ( 
&$wikiPage ) use ( $functionHook ) {
+                       return $functionHook->register( new ArticlePurge( 
$wikiPage ) )->process();
                };
 
                /**
@@ -427,8 +390,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['LinksUpdateConstructed'][] = 
function ( $linksUpdate ) use ( $registry ) {
-                       return $registry->register( new LinksUpdateConstructed( 
$linksUpdate ) )->process();
+               $this->globals['wgHooks']['LinksUpdateConstructed'][] = 
function ( $linksUpdate ) use ( $functionHook ) {
+                       return $functionHook->register( new 
LinksUpdateConstructed( $linksUpdate ) )->process();
                };
 
                /**
@@ -438,8 +401,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['ParserAfterTidy'][] = function ( 
&$parser, &$text ) use ( $registry ) {
-                       return $registry->register( new ParserAfterTidy( 
$parser, $text ) )->process();
+               $this->globals['wgHooks']['ParserAfterTidy'][] = function ( 
&$parser, &$text ) use ( $functionHook ) {
+                       return $functionHook->register( new ParserAfterTidy( 
$parser, $text ) )->process();
                };
 
                /**
@@ -449,8 +412,8 @@
                 *
                 * @since 1.9
                 */
-               $this->globals['wgHooks']['SpecialStatsAddExtra'][] = function 
( &$extraStats ) use ( $registry, $globals ) {
-                       return $registry->register( new SpecialStatsAddExtra( 
$extraStats, $globals['wgVersion'], $globals['wgLang'] ) )->process();
+               $this->globals['wgHooks']['SpecialStatsAddExtra'][] = function 
( &$extraStats ) use ( $functionHook, $globals ) {
+                       return $functionHook->register( new 
SpecialStatsAddExtra( $extraStats, $globals['wgVersion'], $globals['wgLang'] ) 
)->process();
                };
 
                // Old-style registration
@@ -472,8 +435,6 @@
        }
 
        /**
-        * Register parser hooks
-        *
         * @since 1.9
         */
        protected function registerParserHooks() {
diff --git a/tests/phpunit/includes/RecurringEventsTest.php 
b/tests/phpunit/includes/RecurringEventsTest.php
index 4a13f38..956dd13 100644
--- a/tests/phpunit/includes/RecurringEventsTest.php
+++ b/tests/phpunit/includes/RecurringEventsTest.php
@@ -55,29 +55,6 @@
        }
 
        /**
-        * @since  1.9
-        */
-       public function testMissingParametersExceptions() {
-
-               $this->setExpectedException( 'PHPUnit_Framework_Error' );
-               $this->assertInstanceOf( $this->getClass(), new 
RecurringEvents( '' , ''  ) );
-
-       }
-
-       /**
-        * @dataProvider getParametersDataProvider
-        *
-        * @since 1.9
-        */
-       public function testMissingOptionsExceptions( array $params ) {
-               $this->setExpectedException( 'PHPUnit_Framework_Error' );
-               $parameters = new ParserParameterFormatter( $params );
-
-               $instance = new RecurringEvents( $parameters, '' );
-               $this->assertInstanceOf( $this->getClass(), $instance );
-       }
-
-       /**
         * @dataProvider getParametersDataProvider
         *
         * @since 1.9
diff --git a/tests/phpunit/includes/SetupTest.php 
b/tests/phpunit/includes/SetupTest.php
index 03e35c3..a54511c 100644
--- a/tests/phpunit/includes/SetupTest.php
+++ b/tests/phpunit/includes/SetupTest.php
@@ -27,10 +27,32 @@
 
        /**
         * @since 1.9
+        */
+       private function newExtensionContext( $store = null ) {
+
+               $context = new ExtensionContext();
+
+               $settings = $context->getSettings();
+               $settings->set( 'smwgCacheType', CACHE_NONE );
+
+               $context->getDependencyBuilder()
+                       ->getContainer()
+                       ->registerObject( 'Store', 
$this->newMockBuilder()->newObject( 'Store' ) );
+
+               return $context;
+       }
+
+       /**
+        * @since 1.9
         *
         * @return Setup
         */
        private function newInstance( &$test = array(), $context = null ) {
+
+               if ( $context === null ) {
+                       $context = $this->newExtensionContext();
+               }
+
                return new Setup( $test, $context );
        }
 
@@ -100,16 +122,12 @@
         */
        private function assertHook( $hook, &$setup, $count ) {
 
-               $mockLang  = $this->newMockBuilder()->newObject( 'Language' );
-               $mockStore = $this->newMockBuilder()->newObject( 'Store' );
-
-               $context = new ExtensionContext();
-               
$context->getDependencyBuilder()->getContainer()->registerObject( 'Store', 
$mockStore );
+               $mockLang = $this->newMockBuilder()->newObject( 'Language' );
 
                $setup['wgVersion'] = '1.21';
                $setup['wgLang']    = $mockLang;
 
-               $instance = $this->newInstance( $setup, $context );
+               $instance = $this->newInstance( $setup );
 
                $this->assertCount(
                        0,
diff --git a/tests/phpunit/includes/hooks/FunctionHookDBIntegrationTest.php 
b/tests/phpunit/includes/hooks/FunctionHookDBIntegrationTest.php
index 401b4fb..79ffe66 100644
--- a/tests/phpunit/includes/hooks/FunctionHookDBIntegrationTest.php
+++ b/tests/phpunit/includes/hooks/FunctionHookDBIntegrationTest.php
@@ -24,13 +24,38 @@
  *
  * @author mwjames
  */
-class FunctionHookIntegrationTest extends \MediaWikiTestCase {
+class FunctionHookDBIntegrationTest extends \MediaWikiTestCase {
 
        /**
         * @return string|false
         */
        public function getClass() {
                return false;
+       }
+
+       /**
+        * @since 1.9
+        */
+       public function newExtensionContext() {
+
+               $context = new ExtensionContext();
+
+               $settings = $context->getSettings();
+               $settings->set( 'smwgCacheType', CACHE_NONE );
+
+               $mockBuilder = new MockObjectBuilder();
+
+               $data = $mockBuilder->newObject( 'SemanticData', array(
+                       'hasVisibleProperties' => false,
+               ) );
+
+               $store = $mockBuilder->newObject( 'Store', array(
+                       'getSemanticData' => $data,
+               ) );
+
+               
$context->getDependencyBuilder()->getContainer()->registerObject( 'Store', 
$store );
+
+               return $context;
        }
 
        /**
@@ -63,10 +88,10 @@
         */
        public function testOnArticlePurgeOnDatabase() {
 
-               $wikiPage = $this->newWikiPage();
+               $wikiPage = $this->newWikiPage( __METHOD__ );
 
                $instance = new ArticlePurge( $wikiPage );
-               $instance->invokeContext( new ExtensionContext() );
+               $instance->invokeContext( $this->newExtensionContext() );
 
                $this->assertTrue( $instance->process() );
 
@@ -82,14 +107,14 @@
         */
        public function testOnNewRevisionFromEditCompleteOnDatabase() {
 
-               $wikiPage = $this->newWikiPage( 'Bam' );
+               $wikiPage = $this->newWikiPage( __METHOD__ );
 
                $this->assertTrue( $wikiPage->getId() > 0, "WikiPage should 
have new page id" );
                $revision = $wikiPage->getRevision();
                $user = new MockSuperUser();
 
                $instance = new NewRevisionFromEditComplete( $wikiPage, 
$revision, $wikiPage->getId(), $user );
-               $instance->invokeContext( new ExtensionContext() );
+               $instance->invokeContext( $this->newExtensionContext() );
 
                $this->assertTrue( $instance->process() );
 
@@ -106,7 +131,7 @@
        public function testOnOutputPageParserOutputeOnDatabase() {
 
                $text = __METHOD__;
-               $wikiPage = $this->newWikiPage( 'Bar' );
+               $wikiPage = $this->newWikiPage( __METHOD__ );
 
                $title = $wikiPage->getTitle();
 
@@ -118,7 +143,7 @@
                $outputPage = new \OutputPage( $context );
 
                $instance = new OutputPageParserOutput( $outputPage, 
$parserOutput );
-               $instance->invokeContext( new ExtensionContext() );
+               $instance->invokeContext( $this->newExtensionContext() );
 
                $this->assertTrue( $instance->process() );
 
diff --git 
a/tests/phpunit/includes/storage/sqlstore/StatisticsCollectorTest.php 
b/tests/phpunit/includes/storage/sqlstore/StatisticsCollectorTest.php
index 9324129..1f0c258 100644
--- a/tests/phpunit/includes/storage/sqlstore/StatisticsCollectorTest.php
+++ b/tests/phpunit/includes/storage/sqlstore/StatisticsCollectorTest.php
@@ -36,10 +36,17 @@
         *
         * @return StatisticsCollector
         */
-       private function newInstance( $count = 1, $cacheEnabled = false, $hash 
= 'foo' ) {
+       private function newInstance( $count = 55, $cacheEnabled = false, $hash 
= 'foo' ) {
 
-               // $store = $this->newMockObject( array( 'getPropertyTables' => 
array( 'smw_test' ) ) )->getMockStore();
-               $store = StoreFactory::getStore( 'SMWSQLStore3' );
+               $tableDefinition = $this->newMockBuilder()->newObject( 
'SQLStoreTableDefinition', array(
+                       'isFixedPropertyTable' => true
+               ) );
+
+               $store = $this->newMockBuilder()->newObject( 'Store', array(
+                       'getPropertyTables'   => array( 'Foo' => 
$tableDefinition ),
+                       'findTypeTableId'     => 'Foo',
+                       'findPropertyTableID' => 'Foo'
+               ) );
 
                $result = array(
                        'count'  => $count,
@@ -49,28 +56,13 @@
                $resultWrapper = new FakeResultWrapper( array( (object)$result 
) );
                $resultWrapper->count = $count;
 
-               // Database stub object which makes the test
-               // independent from the real DB
-               $connection = $this->getMock( 'DatabaseMysql' );
+               $connection = $this->newMockBuilder()->newObject( 
'DatabaseBase', array(
+                       'select'      => $resultWrapper,
+                       'selectRow'   => $resultWrapper,
+                       'fetchObject' => $resultWrapper,
+                       'estimateRowCount' => $count
+               ) );
 
-               // Override methods with expected return objects
-               $connection->expects( $this->any() )
-                       ->method( 'select' )
-                       ->will( $this->returnValue( $resultWrapper ) );
-
-               $connection->expects( $this->any() )
-                       ->method( 'selectRow' )
-                       ->will( $this->returnValue( $resultWrapper ) );
-
-               $connection->expects( $this->any() )
-                       ->method( 'fetchObject' )
-                       ->will( $this->returnValue( $resultWrapper ) );
-
-               $connection->expects( $this->any() )
-                       ->method( 'estimateRowCount' )
-                       ->will( $this->returnValue( $count ) );
-
-               // Settings to be used
                $settings = $this->newSettings( array(
                        'smwgCacheType' => 'hash',
                        'smwgStatisticsCache' => $cacheEnabled,
@@ -129,6 +121,7 @@
                // Sample A
                $instance = $this->newInstance( $test['A'], 
$test['cacheEnabled'] );
                $result = $instance->getResults();
+
                $this->assertEquals( $expected['A'], $result['OWNPAGE'] );
 
                // Sample B
diff --git a/tests/phpunit/mocks/MockObjectRepository.php 
b/tests/phpunit/mocks/MockObjectRepository.php
index 2b34368..d248223 100644
--- a/tests/phpunit/mocks/MockObjectRepository.php
+++ b/tests/phpunit/mocks/MockObjectRepository.php
@@ -345,14 +345,14 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $parserOutput->expects( $this->any() )
-                       ->method( 'getExtensionData' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getExtensionData' ) ) );
 
-               $parserOutput->expects( $this->any() )
-                       ->method( 'setExtensionData' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'setExtensionData' ) ) );
+               foreach ( $this->builder->getInvokedMethods() as $method ) {
 
+                       $parserOutput->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
+
+               }
 
                return $parserOutput;
        }
@@ -523,18 +523,6 @@
                        ->getMock();
 
                $property->expects( $this->any() )
-                       ->method( 'isUserDefined' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'isUserDefined' ) ) );
-
-               $property->expects( $this->any() )
-                       ->method( 'isShown' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'isShown' ) ) );
-
-               $property->expects( $this->any() )
-                       ->method( 'getDiWikiPage' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getDiWikiPage' ) ) );
-
-               $property->expects( $this->any() )
                        ->method( 'findPropertyTypeID' )
                        ->will( $this->returnValue( $this->builder->setValue( 
'findPropertyTypeID', '_wpg' ) ) );
 
@@ -546,9 +534,13 @@
                        ->method( 'getDIType' )
                        ->will( $this->returnValue( SMWDataItem::TYPE_PROPERTY 
) );
 
-               $property->expects( $this->any() )
-                       ->method( 'getLabel' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getLabel' ) ) );
+               foreach ( $this->builder->getInvokedMethods() as $method ) {
+
+                       $property->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
+
+               }
 
                return $property;
        }
@@ -771,17 +763,13 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $skin->expects( $this->any() )
-                       ->method( 'getTitle' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getTitle' ) ) );
+               foreach ( $this->builder->getInvokedMethods() as $method ) {
 
-               $skin->expects( $this->any() )
-                       ->method( 'getOutput' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getOutput' ) ) );
+                       $skin->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
 
-               $skin->expects( $this->any() )
-                       ->method( 'getContext' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getContext' ) ) );
+               }
 
                return $skin;
        }
@@ -819,17 +807,13 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $parser->expects( $this->any() )
-                       ->method( 'getOutput' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getOutput' ) ) );
+               foreach ( $this->builder->getInvokedMethods() as $method ) {
 
-               $parser->expects( $this->any() )
-                       ->method( 'getTitle' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getTitle' ) ) );
+                       $parser->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
 
-               $parser->expects( $this->any() )
-                       ->method( 'getTargetLanguage' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getTargetLanguage' ) ) );
+               }
 
                return $parser;
        }
@@ -847,13 +831,13 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $linksUpdate->expects( $this->any() )
-                       ->method( 'getTitle' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getTitle' ) ) );
+               foreach ( $this->builder->getInvokedMethods() as $method ) {
 
-               $linksUpdate->expects( $this->any() )
-                       ->method( 'getParserOutput' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'getParserOutput' ) ) );
+                       $linksUpdate->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
+
+               }
 
                return $linksUpdate;
        }
@@ -906,36 +890,43 @@
 
                // DatabaseBase is an abstract class, use setMethods to 
implement
                // required abstract methods
+               $requiredAbstractMethods = array(
+                       'selectField',
+                       'doQuery',
+                       'getType',
+                       'open',
+                       'fetchObject',
+                       'fetchRow',
+                       'numRows',
+                       'numFields',
+                       'fieldName',
+                       'insertId',
+                       'dataSeek',
+                       'lastErrno',
+                       'lastError',
+                       'fieldInfo',
+                       'indexInfo',
+                       'affectedRows',
+                       'strencode',
+                       'getSoftwareLink',
+                       'getServerVersion',
+                       'closeConnection'
+               );
+
+               $methods = array_unique( array_merge( $requiredAbstractMethods, 
$this->builder->getInvokedMethods() ) );
 
                $databaseBase = $this->getMockBuilder( 'DatabaseBase' )
                        ->disableOriginalConstructor()
-                       ->setMethods( array(
-                               'selectField',
-                               'doQuery',
-                               'getType',
-                               'open',
-                               'fetchObject',
-                               'fetchRow',
-                               'numRows',
-                               'numFields',
-                               'fieldName',
-                               'insertId',
-                               'dataSeek',
-                               'lastErrno',
-                               'lastError',
-                               'fieldInfo',
-                               'indexInfo',
-                               'affectedRows',
-                               'strencode',
-                               'getSoftwareLink',
-                               'getServerVersion',
-                               'closeConnection'
-                       ) )
+                       ->setMethods( $methods )
                        ->getMock();
 
-               $databaseBase->expects( $this->any() )
-                       ->method( 'selectField' )
-                       ->will( $this->returnValue( $this->builder->setValue( 
'selectField' ) ) );
+               foreach ( $this->builder->getInvokedMethods() as $method ) {
+
+                       $databaseBase->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
+
+               }
 
                return $databaseBase;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/94101
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf0dd9d9d29916606ed2fb11d495f81c9f06229a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to