mediawiki-extensions-Relate.../tests/phpunit/HooksTest.php
Sam Smith aa30f477bd Clear extension data in ParserClearState handler
While the related parser function sets the accumulated related pages as
extension data on the parser output
(see RelatedArticles\Hooks::onFuncRelated). The ParserClearState
handler, however, sets the empty list as a property, which is then
stored in the DB.

Changes:

* Make RelatedArticles\Hooks::onParserClearState use
  ParserOutput#setExtensionData, mirroring ::onFuncRelated
* Add a unit test for the the handler

Bug: T115698
Change-Id: I3deaf1e8ee78944250c3f26315ee2450b444a035
2015-10-16 20:33:52 +01:00

35 lines
866 B
PHP

<?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();
$relatedArticles = array( 'Maybeshewill' );
$parserOutput->setExtensionData( 'RelatedArticles', $relatedArticles );
$parserOutput->setProperty( 'RelatedArticles', $relatedArticles );
Hooks::onParserClearState( $parser );
$this->assertEquals(
array(),
$parserOutput->getExtensionData( 'RelatedArticles' ),
'It clears the list of related articles.'
);
$this->assertEquals(
false,
$parserOutput->getProperty( 'RelatedArticles' ),
'[T115698] It unsets the list of related articles that were set as a property.'
);
}
}