2016-12-14 12:54:53 +00:00
|
|
|
<?php
|
2017-03-15 18:07:51 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-12-14 12:54:53 +00:00
|
|
|
|
2017-03-15 18:07:51 +00:00
|
|
|
class PortableInfoboxParsingHelperTest extends TestCase {
|
2016-12-14 12:54:53 +00:00
|
|
|
|
|
|
|
protected function setUp() {
|
|
|
|
parent::setUp();
|
2017-03-15 18:07:51 +00:00
|
|
|
require_once __DIR__ . '/../services/Helpers/PortableInfoboxParsingHelper.php';
|
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
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[ '<includeonly></includeonly><infobox></infobox>', false ],
|
|
|
|
[
|
|
|
|
'<includeonly><infobox></infobox></includeonly> ',
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'parser_tag_version' => PortableInfoboxParserTagController::PARSER_TAG_VERSION,
|
|
|
|
'data' => [],
|
|
|
|
'metadata' => []
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[ '<nowiki><includeonly><infobox></infobox></includeonly></nowiki>', false ],
|
|
|
|
[ '<includeonly><nowiki><infobox></infobox></nowiki></includeonly>', false ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|