jenkins-bot has submitted this change and it was merged.
Change subject: (Bug 47079) onParserAfterTidy was missing an updateOutput()
......................................................................
(Bug 47079) onParserAfterTidy was missing an updateOutput()
Took me more time to write an appropriate test then to fix
the problem
Change-Id: I60798f8f312cacada4efd38c4aed74934ae5b7c7
---
M SemanticMediaWiki.hooks.php
M tests/phpunit/includes/ParserDataTest.php
2 files changed, 51 insertions(+), 2 deletions(-)
Approvals:
Mwjames: Looks good to me, approved
jenkins-bot: Verified
diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php
index 0c73a74..6bc6545 100644
--- a/SemanticMediaWiki.hooks.php
+++ b/SemanticMediaWiki.hooks.php
@@ -494,6 +494,7 @@
$parserData = new SMW\ParserData( $parser->getTitle(),
$parser->getOutput(), $options );
$parserData->addCategories(
$parser->getOutput()->getCategoryLinks() );
$parserData->addDefaultSort( $parser->getDefaultSort() );
+ $parserData->updateOutput();
// If an article was was manually purged/moved ensure that the
store is
// updated as well for all other cases onLinksUpdateConstructed
will
diff --git a/tests/phpunit/includes/ParserDataTest.php
b/tests/phpunit/includes/ParserDataTest.php
index 3c2df8a..a33c09a 100644
--- a/tests/phpunit/includes/ParserDataTest.php
+++ b/tests/phpunit/includes/ParserDataTest.php
@@ -64,8 +64,8 @@
*
* @return SMW\ParserData
*/
- private function getInstance( $titleName, ParserOutput $parserOutput ) {
- return new ParserData( $this->getTitle( $titleName ),
$parserOutput );
+ private function getInstance( $titleName, ParserOutput $parserOutput,
array $settings = array() ) {
+ return new ParserData( $this->getTitle( $titleName ),
$parserOutput, $settings );
}
/**
@@ -124,4 +124,52 @@
}
}
+ /**
+ * @covers SMWHooks::onParserAfterTidy
+ *
+ * @see Bug 47079
+ *
+ * @since 1.9
+ */
+ public function testOnParserAfterTidy() {
+ $categories = array( 'Foo', 'Bar' );
+ $settings = array(
+ 'smwgUseCategoryHierarchy' => true,
+ 'smwgCategoriesAsInstances' => true,
+ );
+
+ $instance = $this->getInstance( 'Foo',
$this->getParserOutput(), $settings );
+ $instance->addCategories( $categories );
+
+ // Get semantic data from the ParserOutput that where stored/or
not
+ $parserData = $this->getInstance( 'Foo',
$instance->getOutput(), $settings );
+
+ // Check the returned instance
+ $this->assertInstanceOf( 'SMWSemanticData',
$parserData->getData() );
+ $this->assertCount( 0, $parserData->getErrors() );
+
+ // Bug 47079 updateOutput() was missing therefore resulting in
count = 0
+ $this->assertCount( 0, $parserData->getData()->getProperties()
);
+
+ // Doing the whole thing again but this time executing
updateOutput()
+ $instance = $this->getInstance( 'Bar',
$this->getParserOutput(), $settings );
+ $instance->addCategories( $categories );
+ $instance->updateOutput();
+
+ $parserData = $this->getInstance( 'Bar',
$instance->getOutput(), $settings );
+
+ // Check the returned instance
+ $this->assertInstanceOf( 'SMWSemanticData',
$parserData->getData() );
+ $this->assertCount( 0, $parserData->getErrors() );
+
+ // Bug 47079 execute updateOutput(), resulting in count = 1
+ $this->assertCount( 1, $parserData->getData()->getProperties()
);
+
+ // Category property is available for further processing
+ foreach ( $parserData->getData()->getProperties() as $key =>
$diproperty ){
+ $this->assertInstanceOf( 'SMWDIProperty', $diproperty );
+ $this->assertEquals( '__sin',
$diproperty->findPropertyTypeID() );
+ $this->assertCount( 2,
$parserData->getData()->getPropertyValues( $diproperty ) );
+ }
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/58547
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I60798f8f312cacada4efd38c4aed74934ae5b7c7
Gerrit-PatchSet: 2
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