Remove uncessary ParserClearState hook

The ParserOutput object is already reset when state is reset, so there's no
point in setting or unsetting properties on it.

And since the only unit test was deleted, remove the hook for that too.

Change-Id: Idf12365e8c4b14e527d923edc1086bdaf349df32
This commit is contained in:
Kunal Mehta 2016-07-12 16:02:39 -07:00
parent 6672ea7866
commit a4c4f6700f
3 changed files with 0 additions and 76 deletions

View file

@ -20,9 +20,6 @@
"RelatedArticlesMagic": "RelatedArticles.i18n.magic.php"
},
"Hooks": {
"UnitTestsList": [
"RelatedArticles\\Hooks::onUnitTestsList"
],
"ResourceLoaderTestModules": [
"RelatedArticles\\Hooks::onResourceLoaderTestModules"
],
@ -30,9 +27,6 @@
"ParserFirstCallInit": [
"RelatedArticles\\Hooks::onParserFirstCallInit"
],
"ParserClearState": [
"RelatedArticles\\Hooks::onParserClearState"
],
"OutputPageParserOutput": [
"RelatedArticles\\Hooks::onOutputPageParserOutput"
],

View file

@ -55,27 +55,6 @@ class Hooks {
return '';
}
/**
* Handler for the <code>ParserClearState</code> hook.
*
* Empties the internal list so that related pages are not passed on to future
* ParserOutput's - note that {{#related:Foo}} appends and can be used multiple times
* in the page.
*
* @param Parser $parser
* @return boolean Always <code>true</code>
*/
public static function onParserClearState( Parser &$parser ) {
$parserOutput = $parser->getOutput();
$parserOutput->setExtensionData( 'RelatedArticles', [] );
// FIXME: Remove in 30 days (T115698)
$parserOutput->unsetProperty( 'RelatedArticles' );
return true;
}
/**
* Passes the related pages list from the cached parser output
* object to the output page for rendering.
@ -97,21 +76,6 @@ class Hooks {
return true;
}
/**
* Handler for the <code>UnitTestsList</code> hook.
*
* Adds the path to this extension's PHPUnit test suite to the set of
* paths.
*
* @param array $paths
* @return boolean Always <code>true</code>
*/
public static function onUnitTestsList( array &$paths ) {
$paths[] = __DIR__ . '/../tests/phpunit';
return true;
}
/**
* Register QUnit tests.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules

View file

@ -1,34 +0,0 @@
<?php
namespace Tests\RelatedArticles;
use PHPUnit_Framework_TestCase;
use Parser;
use ParserOutput;
use RelatedArticles\Hooks;
class HooksTest extends PHPUnit_Framework_TestCase {
public function test_onParserClearState() {
$parser = new Parser();
$parserOutput = $parser->mOutput = new ParserOutput();
$relatedPages = [ 'Maybeshewill' ];
$parserOutput->setExtensionData( 'RelatedArticles', $relatedPages );
$parserOutput->setProperty( 'RelatedArticles', $relatedPages );
Hooks::onParserClearState( $parser );
$this->assertEquals(
[],
$parserOutput->getExtensionData( 'RelatedArticles' ),
'It clears the list of related pages.'
);
$this->assertEquals(
false,
$parserOutput->getProperty( 'RelatedArticles' ),
'[T115698] It unsets the list of related pages that were set as a property.'
);
}
}