jenkins-bot has submitted this change and it was merged.
Change subject: Minor renaming
......................................................................
Minor renaming
For the sake of consistency DispatchableSource -> DispatchableSubject
Change-Id: I0fe4347db64a86d2fd3c9c5d22bcd55bb468c06a
---
M includes/ObservableSubject.php
M includes/ObservableSubjectDispatcher.php
M includes/Observer.php
M includes/ParserData.php
M includes/PropertyChangeNotifier.php
M includes/Setup.php
M tests/phpunit/MockObjectBuilder.php
M tests/phpunit/includes/ObservableSubjectDispatcherTest.php
M tests/phpunit/includes/PropertyChangeNotifierTest.php
9 files changed, 71 insertions(+), 49 deletions(-)
Approvals:
Mwjames: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/ObservableSubject.php b/includes/ObservableSubject.php
index 1ef9e4c..d907b9c 100644
--- a/includes/ObservableSubject.php
+++ b/includes/ObservableSubject.php
@@ -75,7 +75,7 @@
*
* @since 1.9
*/
- public function getSource();
+ public function getSubject();
}
@@ -167,13 +167,13 @@
}
/**
- * @see Observable::getSource
+ * @see Observable::getSubject
*
* @since 1.9
*
* @return Observable
*/
- public function getSource() {
+ public function getSubject() {
return $this;
}
diff --git a/includes/ObservableSubjectDispatcher.php
b/includes/ObservableSubjectDispatcher.php
index f8e5d29..44981fb 100644
--- a/includes/ObservableSubjectDispatcher.php
+++ b/includes/ObservableSubjectDispatcher.php
@@ -15,20 +15,20 @@
*/
/**
- * Interface describing a source that is dispatchable
+ * Interface describing a Subject that is dispatchable
*
* @ingroup Observer
*/
-interface DispatchableSource {
+interface DispatchableSubject {
/**
- * Frowards requests fo
+ * Forwards requests to a ObservableDispatcher
*
* @since 1.9
*
- * @param Dispatchable $dispatcher
+ * @param ObservableDispatcher $dispatcher
*/
- public function setDispatcher( ObservableDispatcher $dispatcher );
+ public function setObservableDispatcher( ObservableDispatcher
$dispatcher );
}
@@ -49,9 +49,9 @@
*
* @since 1.9
*
- * @param mixed $source
+ * @param mixed $subject
*/
- public function setSource( $source );
+ public function setSubject( DispatchableSubject $subject );
}
@@ -64,7 +64,7 @@
* @par Example:
* @code
* $changeNotifier = new PropertyChangeNotifier( ... );
- * $changeNotifier->setDispatcher( new ObservableSubjectDispatcher( new
ChangeObserver() ) );
+ * $changeNotifier->setObservableDispatcher( new ObservableSubjectDispatcher(
new ChangeObserver() ) );
* @endcode
*
* @ingroup Observer
@@ -72,19 +72,19 @@
class ObservableSubjectDispatcher extends ObservableSubject implements
ObservableDispatcher {
/** @var mixed */
- protected $source = null;
+ protected $subject = null;
/**
- * Registeres the DispatchableSource
+ * Registeres a DispatchableSubject
*
* @since 1.9
*
- * @param $source
+ * @param $subject
*
* @return ObservableSubjectDispatcher
*/
- public function setSource( $source ) {
- $this->source = $source;
+ public function setSubject( DispatchableSubject $subject ) {
+ $this->subject = $subject;
return $this;
}
@@ -97,8 +97,8 @@
*
* @return mixed
*/
- public function getSource() {
- return $this->source;
+ public function getSubject() {
+ return $this->subject;
}
}
diff --git a/includes/Observer.php b/includes/Observer.php
index 90b3617..a52e731 100644
--- a/includes/Observer.php
+++ b/includes/Observer.php
@@ -26,9 +26,9 @@
*
* @since 1.9
*
- * @param Observable $source
+ * @param Observable $observable
*/
- public function update( Observable $source );
+ public function update( Observable $observable );
}
@@ -43,12 +43,12 @@
/**
* @since 1.9
*
- * @param Observable|null $subject
+ * @param Observable|null $observable
*/
- public function __construct( Observable $subject = null ) {
+ public function __construct( Observable $observable = null ) {
- if ( $subject instanceof Observable ) {
- $subject->attach( $this );
+ if ( $observable instanceof Observable ) {
+ $observable->attach( $this );
}
}
@@ -58,14 +58,14 @@
*
* @since 1.9
*
- * @param Observable|null $subject
+ * @param Observable|null $observable
*/
- public function update( Observable $subject ) {
+ public function update( Observable $observable ) {
- if ( method_exists( $this, $subject->getState() ) ) {
+ if ( method_exists( $this, $observable->getState() ) ) {
call_user_func_array(
- array( $this, $subject->getState() ),
- array( $subject->getSource() )
+ array( $this, $observable->getState() ),
+ array( $observable->getSubject() )
);
}
}
diff --git a/includes/ParserData.php b/includes/ParserData.php
index 9b7b401..307f6e8 100644
--- a/includes/ParserData.php
+++ b/includes/ParserData.php
@@ -405,7 +405,7 @@
// even finding uses of a property fails after its type was
changed.
if ( $this->updateJobs ) {
$changeNotifier = new PropertyChangeNotifier( $store,
$this->semanticData, Settings::newFromGlobals() );
- $changeNotifier->setDispatcher( new
ObservableSubjectDispatcher( new ChangeObserver() ) )->detectChanges();
+ $changeNotifier->setObservableDispatcher( new
ObservableSubjectDispatcher( new ChangeObserver() ) )->detectChanges();
}
// Actually store semantic data, or at least clear it if needed
diff --git a/includes/PropertyChangeNotifier.php
b/includes/PropertyChangeNotifier.php
index 072e0b4..ed1d9bd 100644
--- a/includes/PropertyChangeNotifier.php
+++ b/includes/PropertyChangeNotifier.php
@@ -19,7 +19,7 @@
*
* @ingroup SMW
*/
-class PropertyChangeNotifier implements TitleAccess, DispatchableSource {
+class PropertyChangeNotifier implements TitleAccess, DispatchableSubject {
/** @var Store */
protected $store;
@@ -67,8 +67,8 @@
*
* @param ObservableDispatcher $dispatcher
*/
- public function setDispatcher( ObservableDispatcher $dispatcher ) {
- $this->dispatcher = $dispatcher->setSource( $this );
+ public function setObservableDispatcher( ObservableDispatcher
$dispatcher ) {
+ $this->dispatcher = $dispatcher->setSubject( $this );
return $this;
}
diff --git a/includes/Setup.php b/includes/Setup.php
index eb6f5cb..dd01bef 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -169,7 +169,7 @@
$wgAutoloadClasses['SMW\Subscriber'] = $incDir .
'Observer.php';
$wgAutoloadClasses['SMW\ObservableDispatcher'] = $incDir .
'ObservableSubjectDispatcher.php';
- $wgAutoloadClasses['SMW\DispatchableSource'] = $incDir .
'ObservableSubjectDispatcher.php';
+ $wgAutoloadClasses['SMW\DispatchableSubject'] = $incDir .
'ObservableSubjectDispatcher.php';
$wgAutoloadClasses['SMW\ObservableSubjectDispatcher'] = $incDir .
'ObservableSubjectDispatcher.php';
$wgAutoloadClasses['SMW\Cacheable'] = $incDir .
'Cacheable.php';
diff --git a/tests/phpunit/MockObjectBuilder.php
b/tests/phpunit/MockObjectBuilder.php
index 37a9f2d..ce76915 100644
--- a/tests/phpunit/MockObjectBuilder.php
+++ b/tests/phpunit/MockObjectBuilder.php
@@ -141,6 +141,10 @@
->will( $this->returnValue( $this->setValue( 'getData'
) ) );
$parserData->expects( $this->any() )
+ ->method( 'getTitle' )
+ ->will( $this->returnValue( $this->setValue( 'getTitle'
) ) );
+
+ $parserData->expects( $this->any() )
->method( 'getSubject' )
->will( $this->returnValue( $this->setValue(
'getSubject' ) ) );
@@ -548,7 +552,9 @@
'getPropertySubjects',
'refreshConceptCache',
'deleteConceptCache',
- 'getConceptCacheStatus'
+ 'getConceptCacheStatus',
+ 'clearData',
+ 'updateData'
) )
->getMock();
@@ -600,6 +606,14 @@
->will( $this->setCallback( 'getQueryResult' ) );
$store->expects( $this->any() )
+ ->method( 'updateData' )
+ ->will( $this->setCallback( 'updateData' ) );
+
+ $store->expects( $this->any() )
+ ->method( 'clearData' )
+ ->will( $this->setCallback( 'clearData' ) );
+
+ $store->expects( $this->any() )
->method( 'getAllPropertySubjects' )
->will( $this->setCallback( 'getAllPropertySubjects' )
);
diff --git a/tests/phpunit/includes/ObservableSubjectDispatcherTest.php
b/tests/phpunit/includes/ObservableSubjectDispatcherTest.php
index 575a66f..e5913e1 100644
--- a/tests/phpunit/includes/ObservableSubjectDispatcherTest.php
+++ b/tests/phpunit/includes/ObservableSubjectDispatcherTest.php
@@ -28,6 +28,8 @@
*/
class ObservableSubjectDispatcherTest extends SemanticMediaWikiTestCase {
+ protected $subject = null;
+
/**
* Returns the name of the class to be tested
*
@@ -38,23 +40,23 @@
}
/**
- * Helper method that returns a DispatchableSource object
+ * Helper method that returns a DispatchableSubject object
*
* @since 1.9
*
* @param $data
*
- * @return DispatchableSource
+ * @return DispatchableSubject
*/
- private function newDispatchableSource() {
+ private function newDispatchableSubject() {
- $source = $this->getMockBuilder( '\SMW\DispatchableSource' )
- ->setMethods( array( 'setDispatcher' ) )
+ $source = $this->getMockBuilder( '\SMW\DispatchableSubject' )
+ ->setMethods( array( 'setObservableDispatcher' ) )
->getMock();
$source->expects( $this->any() )
- ->method( 'setDispatcher' )
- ->will( $this->returnCallback( array( $this,
'setDispatcherCallback' ) ) );
+ ->method( 'setObservableDispatcher' )
+ ->will( $this->returnCallback( array( $this,
'setObservableDispatcherCallback' ) ) );
return $source;
@@ -132,16 +134,17 @@
$dispatcher = $this->getInstance( $this->newObserver() );
// Register dispatcher with a source
- $source = $this->newDispatchableSource();
- $source->setDispatcher( $dispatcher );
+ $source = $this->newDispatchableSubject();
+ $source->setObservableDispatcher( $dispatcher );
// Rather being the source itself, the dispatcher returns the
invoked instance
- $this->assertEquals( $this, $dispatcher->getSource() );
+ $this->assertInstanceOf( '\SMW\DispatchableSubject',
$this->subject );
+ $this->assertEquals( $this->subject, $dispatcher->getSubject()
);
// The dipatchers forwards a registered state change but the
Observer
// is using the invoked source ($this) as means to communicate
$dispatcher->setState( 'lila' );
- $this->assertEquals( 'lilaObserver was informed by source',
$this->ObserverSentAMessage );
+ $this->assertEquals( 'lilaObserver was informed by source',
$this->subject->ObserverSentAMessage );
}
@@ -163,8 +166,13 @@
*
* @param ObservableDispatcher $dispatcher
*/
- public function setDispatcherCallback( ObservableDispatcher $dispatcher
) {
- $dispatcher->setSource( $this );
+ public function setObservableDispatcherCallback( ObservableDispatcher
$dispatcher ) {
+
+ $this->subject = $this->getMockBuilder(
'\SMW\DispatchableSubject' )
+ ->setMethods( array( 'setObservableDispatcher' ) )
+ ->getMock();
+
+ $dispatcher->setSubject( $this->subject );
}
}
diff --git a/tests/phpunit/includes/PropertyChangeNotifierTest.php
b/tests/phpunit/includes/PropertyChangeNotifierTest.php
index 96a3664..ce3590e 100644
--- a/tests/phpunit/includes/PropertyChangeNotifierTest.php
+++ b/tests/phpunit/includes/PropertyChangeNotifierTest.php
@@ -95,7 +95,7 @@
$instance = $this->getInstance( $store, $data, $settings );
$observer = new MockChangeObserver();
- $instance->setDispatcher( new ObservableSubjectDispatcher(
$observer ) );
+ $instance->setObservableDispatcher( new
ObservableSubjectDispatcher( $observer ) );
$this->assertInstanceOf( $this->getClass(),
$instance->detectChanges() );
$this->assertEquals( $subject->getTitle(),
$instance->getTitle() );
--
To view, visit https://gerrit.wikimedia.org/r/78141
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0fe4347db64a86d2fd3c9c5d22bcd55bb468c06a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[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