PortableInfobox/tests/phpunit/PortableInfoboxParsingHelperTest.php

65 lines
1.8 KiB
PHP
Raw Normal View History

2016-12-14 12:54:53 +00:00
<?php
2018-08-08 09:42:22 +00:00
/**
* @group PortableInfobox
* @covers Wikia\PortableInfobox\Helpers\PortableInfoboxParsingHelper
*/
class PortableInfoboxParsingHelperTest extends MediaWikiTestCase {
2016-12-14 12:54:53 +00:00
/**
2017-03-15 18:07:51 +00:00
* @dataProvider parsingIncludeonlyInfoboxesDataProvider
2016-12-14 12:54:53 +00:00
*/
public function testParsingIncludeonlyInfoboxes( $markup, $expected ) {
2017-03-15 18:07:51 +00:00
/** @var PHPUnit_Framework_MockObject_MockObject|\Wikia\PortableInfobox\Helpers\PortableInfoboxParsingHelper $helper */
$helper = $this->getMockBuilder( \Wikia\PortableInfobox\Helpers\PortableInfoboxParsingHelper::class )
->setMethods( [ 'fetchArticleContent' ] )
->getMock();
$helper->expects( $this->once() )
->method( 'fetchArticleContent' )
->willReturn( $markup );
2016-12-14 12:54:53 +00:00
$result = $helper->parseIncludeonlyInfoboxes( new Title() );
$this->assertEquals( $expected, $result );
}
2017-03-15 18:07:51 +00:00
public function parsingIncludeonlyInfoboxesDataProvider() {
2016-12-14 12:54:53 +00:00
return [
[ 'test', false ],
[
'<includeonly><infobox><data source="test"><label>1</label></data></infobox></includeonly>',
[
[
'parser_tag_version' => PortableInfoboxParserTagController::PARSER_TAG_VERSION,
'data' => [],
'metadata' => [
[
'type' => 'data',
'sources' => [
'test' => [
'label' => '1',
'primary' => true
]
]
]
]
]
]
],
2018-08-08 09:42:22 +00:00
[ '<noinclude><infobox></infobox></noinclude>', false ],
[ '<onlyinclude></onlyinclude><infobox></infobox>', false ],
2016-12-14 12:54:53 +00:00
[
2018-08-08 09:42:22 +00:00
'<includeonly></includeonly><infobox></infobox>',
2016-12-14 12:54:53 +00:00
[
[
'parser_tag_version' => PortableInfoboxParserTagController::PARSER_TAG_VERSION,
'data' => [],
'metadata' => []
]
]
],
[ '<nowiki><includeonly><infobox></infobox></includeonly></nowiki>', false ],
[ '<includeonly><nowiki><infobox></infobox></nowiki></includeonly>', false ],
];
}
}