Jeroen De Dauw has submitted this change and it was merged.

Change subject: Remove MW dependency from PredefinedPropertyAnnotator
......................................................................


Remove MW dependency from PredefinedPropertyAnnotator

Using a PageInfoProvider to encapsulate relevant MW objects

Change-Id: Icd2c39394e5f37f8f78bfce147f562212a45d6f6
---
M SemanticMediaWiki.classes.php
A includes/MediaWikiPageInfoProvider.php
A includes/annotator/PageInfoProvider.php
M includes/annotator/PredefinedPropertyAnnotator.php
M includes/dic/SharedDependencyContainer.php
A tests/phpunit/includes/MediaWikiPageInfoProviderTest.php
M tests/phpunit/includes/annotator/ChainablePropertyAnnotatorTest.php
M tests/phpunit/includes/annotator/PredefinedPropertyAnnotatorTest.php
M tests/phpunit/mocks/CoreMockObjectRepository.php
9 files changed, 393 insertions(+), 121 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/SemanticMediaWiki.classes.php b/SemanticMediaWiki.classes.php
index 5ade358..9befcc0 100644
--- a/SemanticMediaWiki.classes.php
+++ b/SemanticMediaWiki.classes.php
@@ -47,15 +47,17 @@
        'SMW\SimpleDictionary'          => 'includes/SimpleDictionary.php',
        'SMW\StoreUpdater'              => 'includes/StoreUpdater.php',
        'SMW\LazyDBConnectionProvider'  => 
'includes/LazyDBConnectionProvider.php',
+       'SMW\MediaWikiPageInfoProvider' => 
'includes/MediaWikiPageInfoProvider.php',
 
        // Annotator
-       'SMW\PropertyAnnotator'                  => 
'includes/annotator/PropertyAnnotator.php',
-       'SMW\NullPropertyAnnotator'              => 
'includes/annotator/NullPropertyAnnotator.php',
-       'SMW\PropertyAnnotatorDecorator'         => 
'includes/annotator/PropertyAnnotatorDecorator.php',
-       'SMW\CategoryPropertyAnnotator'          => 
'includes/annotator/CategoryPropertyAnnotator.php',
-       'SMW\SortKeyPropertyAnnotator'           => 
'includes/annotator/SortKeyPropertyAnnotator.php',
-       'SMW\PredefinedPropertyAnnotator'        => 
'includes/annotator/PredefinedPropertyAnnotator.php',
-       'SMW\RedirectPropertyAnnotator'          => 
'includes/annotator/RedirectPropertyAnnotator.php',
+       'SMW\PropertyAnnotator'              => 
'includes/annotator/PropertyAnnotator.php',
+       'SMW\NullPropertyAnnotator'          => 
'includes/annotator/NullPropertyAnnotator.php',
+       'SMW\PropertyAnnotatorDecorator'     => 
'includes/annotator/PropertyAnnotatorDecorator.php',
+       'SMW\CategoryPropertyAnnotator'      => 
'includes/annotator/CategoryPropertyAnnotator.php',
+       'SMW\SortKeyPropertyAnnotator'       => 
'includes/annotator/SortKeyPropertyAnnotator.php',
+       'SMW\RedirectPropertyAnnotator'      => 
'includes/annotator/RedirectPropertyAnnotator.php',
+       'SMW\PageInfoProvider'               => 
'includes/annotator/PageInfoProvider.php',
+       'SMW\PredefinedPropertyAnnotator'    => 
'includes/annotator/PredefinedPropertyAnnotator.php',
 
        'SMW\TitleAccess'               => 
'includes/interfaces/TitleAccess.php',
        'SMW\ResultCollector'           => 
'includes/interfaces/ResultCollector.php',
diff --git a/includes/MediaWikiPageInfoProvider.php 
b/includes/MediaWikiPageInfoProvider.php
new file mode 100644
index 0000000..1b5bb68
--- /dev/null
+++ b/includes/MediaWikiPageInfoProvider.php
@@ -0,0 +1,85 @@
+<?php
+
+namespace SMW;
+
+use WikiPage;
+use Revision;
+use User;
+
+/**
+ * Provide access to MediaWiki objects relevant for the predefined property
+ * annotation process
+ *
+ * @ingroup SMW
+ *
+ * @licence GNU GPL v2+
+ * @since 1.9
+ *
+ * @author mwjames
+ */
+class MediaWikiPageInfoProvider implements PageInfoProvider {
+
+       /** @var WikiPage */
+       protected $wikiPage;
+
+       /** @var Revision */
+       protected $revision;
+
+       /** @var User */
+       protected $user;
+
+       /**
+        * @since 1.9
+        *
+        * @param WikiPage $wikiPage
+        * @param Revision $revision
+        * @param User $user
+        */
+       public function __construct( WikiPage $wikiPage, Revision $revision, 
User $user ) {
+               $this->wikiPage = $wikiPage;
+               $this->revision = $revision;
+               $this->user = $user;
+       }
+
+       /**
+        * @since 1.9
+        *
+        * @return integer
+        */
+       public function getModificationDate() {
+               return $this->wikiPage->getTimestamp();
+       }
+
+       /**
+        * @note getFirstRevision() is expensive as it initiates a read on the
+        * revision table which is not cached
+        *
+        * @since 1.9
+        *
+        * @return integer
+        */
+       public function getCreationDate() {
+               return 
$this->wikiPage->getTitle()->getFirstRevision()->getTimestamp();
+       }
+
+       /**
+        * @note Using isNewPage() is expensice due to access to the database
+        *
+        * @since 1.9
+        *
+        * @return boolean
+        */
+       public function isNewPage() {
+               return $this->revision->getParentId() !== '';
+       }
+
+       /**
+        * @since 1.9
+        *
+        * @return Title
+        */
+       public function getLastEditor() {
+               return $this->user->getUserPage();
+       }
+
+}
\ No newline at end of file
diff --git a/includes/annotator/PageInfoProvider.php 
b/includes/annotator/PageInfoProvider.php
new file mode 100644
index 0000000..fb0a7b2
--- /dev/null
+++ b/includes/annotator/PageInfoProvider.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace SMW;
+
+/**
+ * Facade interface to specify access to page information
+ *
+ * @ingroup SMW
+ *
+ * @licence GNU GPL v2+
+ * @since 1.9
+ *
+ * @author mwjames
+ */
+interface PageInfoProvider {
+
+       /**
+        * Returns a modification date
+        *
+        * @since 1.9
+        *
+        * @return integer
+        */
+       public function getModificationDate();
+
+       /**
+        * Returns a creation date
+        *
+        * @since 1.9
+        *
+        * @return integer
+        */
+       public function getCreationDate();
+
+       /**
+        * Whether the page object is new or not
+        *
+        * @since 1.9
+        *
+        * @return boolean
+        */
+       public function isNewPage();
+
+       /**
+        * Returns a user object for the last editor
+        *
+        * @since 1.9
+        *
+        * @return Title
+        */
+       public function getLastEditor();
+
+}
\ No newline at end of file
diff --git a/includes/annotator/PredefinedPropertyAnnotator.php 
b/includes/annotator/PredefinedPropertyAnnotator.php
index b46534a..4ead508 100644
--- a/includes/annotator/PredefinedPropertyAnnotator.php
+++ b/includes/annotator/PredefinedPropertyAnnotator.php
@@ -7,10 +7,6 @@
 use SMWDIBoolean as DIBoolean;
 use SMWDITime as DITime;
 
-use WikiPage;
-use Revision;
-use User;
-
 /**
  * Handling predefined property annotations
  *
@@ -23,28 +19,18 @@
  */
 class PredefinedPropertyAnnotator extends PropertyAnnotatorDecorator {
 
-       /** @var WikiPage */
-       protected $wikiPage;
-
-       /** @var Revision */
-       protected $revision;
-
-       /** @var User */
-       protected $user;
+       /** @var PageInfoProvider */
+       protected $pageInfo;
 
        /**
         * @since 1.9
         *
         * @param PropertyAnnotator $propertyAnnotator
-        * @param WikiPage $wikiPage
-        * @param Revision $revision
-        * @param User $user
+        * @param PageInfoProvider $pageInfo
         */
-       public function __construct( PropertyAnnotator $propertyAnnotator, 
WikiPage $wikiPage, Revision $revision, User $user ) {
+       public function __construct( PropertyAnnotator $propertyAnnotator, 
PageInfoProvider $pageInfo ) {
                parent::__construct( $propertyAnnotator );
-               $this->wikiPage = $wikiPage;
-               $this->revision = $revision;
-               $this->user = $user;
+               $this->pageInfo = $pageInfo;
        }
 
        /**
@@ -59,41 +45,18 @@
 
                foreach ( $predefinedProperties as $propertyId ) {
 
-                       // Ensure that only special properties are added that 
are registered
-                       // and only added once
-                       if ( ( DIProperty::getPredefinedPropertyTypeId( 
$propertyId ) === '' ) ||
-                               ( array_key_exists( $propertyId, 
$cachedProperties ) ) ) {
+                       if ( $this->assertRegisteredPropertyId( $propertyId, 
$cachedProperties ) ) {
                                continue;
                        }
 
                        $propertyDI = new DIProperty( $propertyId );
 
-                       // Don't do a double round
                        if ( $this->getSemanticData()->getPropertyValues( 
$propertyDI ) !== array() ) {
                                $cachedProperties[ $propertyId ] = true;
                                continue;
                        }
 
-                       switch ( $propertyId ) {
-                               case DIProperty::TYPE_MODIFICATION_DATE :
-                                       $dataItem = DITime::newFromTimestamp( 
$this->wikiPage->getTimestamp() );
-                                       break;
-                               case DIProperty::TYPE_CREATION_DATE :
-                                       // Expensive getFirstRevision() 
initiates a revision table
-                                       // read and is not cached
-                                       $dataItem = DITime::newFromTimestamp(
-                                               
$this->wikiPage->getTitle()->getFirstRevision()->getTimestamp()
-                                       );
-                                       break;
-                               case DIProperty::TYPE_NEW_PAGE :
-                                       // Expensive isNewPage() does a 
database read
-                                       // $dataValue = new SMWDIBoolean( 
$this->title->isNewPage() );
-                                       $dataItem = new DIBoolean( 
$this->revision->getParentId() !== '' );
-                                       break;
-                               case DIProperty::TYPE_LAST_EDITOR :
-                                       $dataItem = DIWikiPage::newFromTitle( 
$this->user->getUserPage() );
-                                       break;
-                       }
+                       $dataItem = $this->createDataItemByPropertyId( 
$propertyId );
 
                        if ( $dataItem instanceof DataItem ) {
                                $cachedProperties[ $propertyId ] = true;
@@ -106,4 +69,37 @@
                return $this;
        }
 
+       /**
+        * @since  1.9
+        */
+       protected function assertRegisteredPropertyId( $propertyId, 
$cachedProperties ) {
+               return ( DIProperty::getPredefinedPropertyTypeId( $propertyId ) 
=== '' ) ||
+                       array_key_exists( $propertyId, $cachedProperties );
+       }
+
+       /**
+        * @since  1.9
+        */
+       protected function createDataItemByPropertyId( $propertyId ) {
+
+               $dataItem = null;
+
+               switch ( $propertyId ) {
+                       case DIProperty::TYPE_MODIFICATION_DATE :
+                               $dataItem = DITime::newFromTimestamp( 
$this->pageInfo->getModificationDate() );
+                               break;
+                       case DIProperty::TYPE_CREATION_DATE :
+                               $dataItem = DITime::newFromTimestamp( 
$this->pageInfo->getCreationDate() );
+                               break;
+                       case DIProperty::TYPE_NEW_PAGE :
+                               $dataItem = new DIBoolean( 
$this->pageInfo->isNewPage() );
+                               break;
+                       case DIProperty::TYPE_LAST_EDITOR :
+                               $dataItem = DIWikiPage::newFromTitle( 
$this->pageInfo->getLastEditor() );
+                               break;
+               }
+
+               return $dataItem;
+       }
+
 }
diff --git a/includes/dic/SharedDependencyContainer.php 
b/includes/dic/SharedDependencyContainer.php
index 5af5cad..f03e4fe 100644
--- a/includes/dic/SharedDependencyContainer.php
+++ b/includes/dic/SharedDependencyContainer.php
@@ -391,8 +391,6 @@
        }
 
        /**
-        * PredefinedPropertyAnnotator object definition
-        *
         * @since  1.9
         *
         * @return PredefinedPropertyAnnotator
@@ -402,12 +400,13 @@
 
                        $annotator = $builder->newObject( 
'NullPropertyAnnotator' );
 
-                       return new PredefinedPropertyAnnotator(
-                               $annotator,
+                       $valueProvider = new MediaWikiPageInfoProvider(
                                $builder->getArgument( 'WikiPage' ),
                                $builder->getArgument( 'Revision' ),
                                $builder->getArgument( 'User' )
                        );
+
+                       return new PredefinedPropertyAnnotator( $annotator, 
$valueProvider );
                };
        }
 
diff --git a/tests/phpunit/includes/MediaWikiPageInfoProviderTest.php 
b/tests/phpunit/includes/MediaWikiPageInfoProviderTest.php
new file mode 100644
index 0000000..bd0e52f
--- /dev/null
+++ b/tests/phpunit/includes/MediaWikiPageInfoProviderTest.php
@@ -0,0 +1,162 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\MediaWikiPageInfoProvider;
+
+/**
+ * @covers \SMW\MediaWikiPageInfoProvider
+ *
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ *
+ * @licence GNU GPL v2+
+ * @since 1.9
+ *
+ * @author mwjames
+ */
+class MediaWikiPageInfoProviderTest extends SemanticMediaWikiTestCase {
+
+       /**
+        * @return string|false
+        */
+       public function getClass() {
+               return '\SMW\MediaWikiPageInfoProvider';
+       }
+
+       /**
+        * @since 1.9
+        *
+        * @return MediaWikiPageInfoProvider
+        */
+       private function newInstance( $wikiPage = null, $revision = null, $user 
= null ) {
+
+               if ( $wikiPage === null ) {
+                       $wikiPage = $this->newMockBuilder()->newObject( 
'WikiPage' );
+               }
+
+               if ( $revision === null ) {
+                       $revision = $this->newMockBuilder()->newObject( 
'Revision' );
+               }
+
+               if ( $user === null ) {
+                       $user = $this->newMockBuilder()->newObject( 'User' );
+               }
+
+               return new MediaWikiPageInfoProvider( $wikiPage, $revision, 
$user );
+       }
+
+       /**
+        * @since 1.9
+        */
+       public function testConstructor() {
+               $this->assertInstanceOf( $this->getClass(), 
$this->newInstance() );
+       }
+
+       /**
+        * @dataProvider instanceDataProvider
+        *
+        * @since 1.9
+        */
+       public function testMethodAccess( array $setup, $expected ) {
+
+               $method = $setup['method'];
+
+               $instance = $this->newInstance(
+                       $this->newMockBuilder()->newObject( 'WikiPage', 
$setup['wikiPage'] ),
+                       $this->newMockBuilder()->newObject( 'Revision', 
$setup['revision'] ),
+                       $this->newMockBuilder()->newObject( 'User', 
$setup['user'] )
+               );
+
+               $this->assertEquals(
+                       $expected['result'],
+                       $instance->{ $method }(),
+                       "Asserts that {$method} returns an expected result"
+               );
+
+       }
+
+       /**
+        * @return array
+        */
+       public function instanceDataProvider() {
+
+               $provider = array();
+
+               // TYPE_MODIFICATION_DATE
+               $provider[] = array(
+                       array(
+                               'wikiPage' => array( 'getTimestamp' => 
1272508903 ),
+                               'revision' => array(),
+                               'user'     => array(),
+                               'method'   => 'getModificationDate'
+                       ),
+                       array(
+                               'result' => 1272508903
+                       )
+               );
+
+               // TYPE_CREATION_DATE
+               $revision = $this->newMockBuilder()->newObject( 'Revision', 
array(
+                       'getTimestamp' => 1272508903
+               ) );
+
+               $title = $this->newMockBuilder()->newObject( 'Title', array(
+                       'getDBkey'         => 'Lula',
+                       'getNamespace'     => NS_MAIN,
+                       'getFirstRevision' => $revision
+               ) );
+
+               $subject = $this->newMockBuilder()->newObject( 'DIWikiPage', 
array(
+                       'getTitle' => $this->newMockBuilder()->newObject( 
'Title' )
+               ) );
+
+               $provider[] = array(
+                       array(
+                               'wikiPage' => array( 'getTitle' => $title ),
+                               'revision' => array(),
+                               'user'     => array(),
+                               'method'   => 'getCreationDate'
+                       ),
+                       array(
+                               'result' => 1272508903
+                       )
+               );
+
+               // TYPE_NEW_PAGE
+               $provider[] = array(
+                       array(
+                               'wikiPage' => array(),
+                               'revision' => array( 'getParentId' => 9001 ),
+                               'user'     => array(),
+                               'method'   => 'isNewPage'
+                       ),
+                       array(
+                               'result' => true
+                       )
+               );
+
+               // TYPE_LAST_EDITOR
+               $userPage = $this->newMockBuilder()->newObject( 'Title', array(
+                       'getDBkey'         => 'Lula',
+                       'getNamespace'     => NS_USER,
+               ) );
+
+               $provider[] = array(
+                       array(
+                               'wikiPage' => array(),
+                               'revision' => array(),
+                               'user'     => array( 'getUserPage' => $userPage 
),
+                               'method'   => 'getLastEditor'
+                       ),
+                       array(
+                               'result' => $userPage
+                       )
+               );
+
+               return $provider;
+       }
+
+}
diff --git 
a/tests/phpunit/includes/annotator/ChainablePropertyAnnotatorTest.php 
b/tests/phpunit/includes/annotator/ChainablePropertyAnnotatorTest.php
index d04fda9..1841d0b 100644
--- a/tests/phpunit/includes/annotator/ChainablePropertyAnnotatorTest.php
+++ b/tests/phpunit/includes/annotator/ChainablePropertyAnnotatorTest.php
@@ -63,9 +63,7 @@
 
                $instance = new PredefinedPropertyAnnotator(
                        $instance,
-                       $this->newMockBuilder()->newObject( 'WikiPage', 
$setup['wikiPage'] ),
-                       $this->newMockBuilder()->newObject( 'Revision', 
$setup['revision'] ),
-                       $this->newMockBuilder()->newObject( 'User', 
$setup['user'] )
+                       $this->newMockBuilder()->newObject( 'PageInfoProvider', 
$setup['pageInfo'] )
                );
 
                $instance->addAnnotation();
@@ -88,12 +86,10 @@
                // #0
                $provider[] = array(
                        array(
+                               'pageInfo' => array( 'getModificationDate' => 
1272508903 ),
                                'namespace'  => NS_MAIN,
                                'categories' => array( 'Foo', 'Bar' ),
                                'sortkey'    => 'Lala',
-                               'wikiPage'   => array( 'getTimestamp' => 
1272508903 ),
-                               'revision'   => array(),
-                               'user'       => array(),
                                'settings'   => array(
                                        'smwgUseCategoryHierarchy'  => false,
                                        'smwgCategoriesAsInstances' => true,
diff --git 
a/tests/phpunit/includes/annotator/PredefinedPropertyAnnotatorTest.php 
b/tests/phpunit/includes/annotator/PredefinedPropertyAnnotatorTest.php
index e85c844..6929a26 100644
--- a/tests/phpunit/includes/annotator/PredefinedPropertyAnnotatorTest.php
+++ b/tests/phpunit/includes/annotator/PredefinedPropertyAnnotatorTest.php
@@ -6,7 +6,6 @@
 use SMW\NullPropertyAnnotator;
 use SMW\EmptyContext;
 use SMW\SemanticData;
-use SMW\DIWikiPage;
 use SMW\DIProperty;
 
 /**
@@ -50,23 +49,13 @@
         *
         * @return PredefinedPropertyAnnotator
         */
-       private function newInstance( $semanticData = null, $settings = 
array(), $wikiPage = null, $revision = null, $user = null ) {
+       private function newInstance( $semanticData = null, $settings = 
array(), $pageInfo = array() ) {
 
                if ( $semanticData === null ) {
                        $semanticData = $this->newMockBuilder()->newObject( 
'SemanticData' );
                }
 
-               if ( $wikiPage === null ) {
-                       $wikiPage = $this->newMockBuilder()->newObject( 
'WikiPage' );
-               }
-
-               if ( $revision === null ) {
-                       $revision = $this->newMockBuilder()->newObject( 
'Revision' );
-               }
-
-               if ( $user === null ) {
-                       $user = $this->newMockBuilder()->newObject( 'User' );
-               }
+               $predefinedProperty = $this->newMockBuilder()->newObject( 
'PageInfoProvider', $pageInfo );
 
                $settings = $this->newSettings( $settings );
 
@@ -74,12 +63,8 @@
                
$context->getDependencyBuilder()->getContainer()->registerObject( 'Settings', 
$settings );
 
                return new PredefinedPropertyAnnotator(
-                       new NullPropertyAnnotator( $semanticData, $context ),
-                       $wikiPage,
-                       $revision,
-                       $user
+                       new NullPropertyAnnotator( $semanticData, $context ), 
$predefinedProperty
                );
-
        }
 
        /**
@@ -98,14 +83,7 @@
 
                $semanticData = new SemanticData( $setup['subject'] );
 
-               $instance = $this->newInstance(
-                       $semanticData,
-                       $setup['settings'],
-                       $this->newMockBuilder()->newObject( 'WikiPage', 
$setup['wikiPage'] ),
-                       $this->newMockBuilder()->newObject( 'Revision', 
$setup['revision'] ),
-                       $this->newMockBuilder()->newObject( 'User', 
$setup['user'] )
-               );
-
+               $instance = $this->newInstance( $semanticData, 
$setup['settings'], $setup['pageInfo'] );
                $instance->attach( $this->newObserver() )->addAnnotation();
 
                $this->assertSemanticData(
@@ -149,9 +127,7 @@
                                'settings' => array(
                                        'smwgPageSpecialProperties' => array( 
'Lala', '_Lula', '-Lila', '' )
                                ),
-                               'wikiPage' => array(),
-                               'revision' => array(),
-                               'user'     => array()
+                               'pageInfo' => array(),
                        ),
                        array(
                                'propertyCount' => 0,
@@ -165,9 +141,7 @@
                                'settings' => array(
                                        'smwgPageSpecialProperties' => array( 
DIProperty::TYPE_MODIFICATION_DATE )
                                ),
-                               'wikiPage' => array( 'getTimestamp' => 
1272508903 ),
-                               'revision' => array(),
-                               'user'     => array()
+                               'pageInfo' => array( 'getModificationDate' => 
1272508903 )
                        ),
                        array(
                                'propertyCount' => 1,
@@ -177,29 +151,13 @@
                );
 
                // TYPE_CREATION_DATE
-               $revision = $this->newMockBuilder()->newObject( 'Revision', 
array(
-                       'getTimestamp' => 1272508903
-               ) );
-
-               $title = $this->newMockBuilder()->newObject( 'Title', array(
-                       'getDBkey'         => 'Lula',
-                       'getNamespace'     => NS_MAIN,
-                       'getFirstRevision' => $revision
-               ) );
-
-               $subject = $this->newMockBuilder()->newObject( 'DIWikiPage', 
array(
-                       'getTitle' => $this->newMockBuilder()->newObject( 
'Title' )
-               ) );
-
                $provider[] = array(
                        array(
-                               'subject'  => $subject,
+                               'subject'  => $this->newSubject( 
$this->newTitle() ),
                                'settings' => array(
                                        'smwgPageSpecialProperties' => array( 
DIProperty::TYPE_CREATION_DATE )
                                ),
-                               'wikiPage' => array( 'getTitle' => $title ),
-                               'revision' => array(),
-                               'user'     => array()
+                               'pageInfo' => array( 'getCreationDate' => 
1272508903 )
                        ),
                        array(
                                'propertyCount' => 1,
@@ -215,9 +173,7 @@
                                'settings' => array(
                                        'smwgPageSpecialProperties' => array( 
DIProperty::TYPE_NEW_PAGE )
                                ),
-                               'wikiPage' => array(),
-                               'revision' => array( 'getParentId' => 9001 ),
-                               'user'     => array()
+                               'pageInfo' => array( 'isNewPage' => true )
                        ),
                        array(
                                'propertyCount' => 1,
@@ -238,9 +194,7 @@
                                'settings' => array(
                                        'smwgPageSpecialProperties' => array( 
DIProperty::TYPE_LAST_EDITOR )
                                ),
-                               'wikiPage' => array(),
-                               'revision' => array(),
-                               'user'     => array( 'getUserPage' => $userPage 
)
+                               'pageInfo' => array( 'getLastEditor' => 
$userPage )
                        ),
                        array(
                                'propertyCount' => 1,
@@ -249,16 +203,17 @@
                        )
                );
 
-               // Combine entries
+               // Combined entries
                $provider[] = array(
                        array(
                                'subject'  => $this->newSubject( 
$this->newTitle() ),
                                'settings' => array(
                                        'smwgPageSpecialProperties' => array( 
'_MDAT', '_LEDT' )
                                ),
-                               'wikiPage' => array( 'getTimestamp' => 
1272508903 ),
-                               'revision' => array(),
-                               'user'     => array( 'getUserPage' => $userPage 
)
+                               'pageInfo' => array(
+                                       'getModificationDate' => 1272508903,
+                                       'getLastEditor'      => $userPage
+                               )
                        ),
                        array(
                                'propertyCount' => 2,
diff --git a/tests/phpunit/mocks/CoreMockObjectRepository.php 
b/tests/phpunit/mocks/CoreMockObjectRepository.php
index fcc267f..a473987 100644
--- a/tests/phpunit/mocks/CoreMockObjectRepository.php
+++ b/tests/phpunit/mocks/CoreMockObjectRepository.php
@@ -662,4 +662,28 @@
                return $queryDescription;
        }
 
+       /**
+        * @since 1.9
+        *
+        * @return PageInfoProvider
+        */
+       public function PageInfoProvider() {
+
+               $methods = $this->builder->getInvokedMethods();
+
+               $adapter = $this->getMockBuilder( 'SMW\PageInfoProvider' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               foreach ( $methods as $method ) {
+
+                       $adapter->expects( $this->any() )
+                               ->method( $method )
+                               ->will( $this->builder->setCallback( $method ) 
);
+
+               }
+
+               return $adapter;
+       }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icd2c39394e5f37f8f78bfce147f562212a45d6f6
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to