mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-12-02 20:06:40 +00:00
73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group PortableInfobox
|
|
* @group Database
|
|
* @covers PortableInfobox\Helpers\PortableInfoboxParsingHelper
|
|
*/
|
|
class PortableInfoboxParsingHelperTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function needsDB() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @dataProvider parsingIncludeonlyInfoboxesDataProvider
|
|
*/
|
|
public function testParsingIncludeonlyInfoboxes( $markup, $expected ) {
|
|
$helper = $this->getMockBuilder( PortableInfobox\Helpers\PortableInfoboxParsingHelper::class )
|
|
->setMethods( [ 'fetchArticleContent' ] )
|
|
->getMock();
|
|
$helper->expects( $this->once() )
|
|
->method( 'fetchArticleContent' )
|
|
->will( $this->returnValue( $markup ) );
|
|
|
|
$result = $helper->parseIncludeonlyInfoboxes( $this->getExistingTestPage( 'Test' )->getTitle() );
|
|
|
|
$this->assertEquals( $expected, $result );
|
|
}
|
|
|
|
public function parsingIncludeonlyInfoboxesDataProvider() {
|
|
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
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
],
|
|
[ '<noinclude><infobox></infobox></noinclude>', false ],
|
|
[ '<onlyinclude></onlyinclude><infobox></infobox>', false ],
|
|
[
|
|
'<includeonly></includeonly><infobox></infobox>',
|
|
[
|
|
[
|
|
'parser_tag_version' => PortableInfoboxParserTagController::PARSER_TAG_VERSION,
|
|
'data' => [],
|
|
'metadata' => []
|
|
]
|
|
]
|
|
],
|
|
[ '<nowiki><includeonly><infobox></infobox></includeonly></nowiki>', false ],
|
|
[ '<includeonly><nowiki><infobox></infobox></nowiki></includeonly>', false ],
|
|
];
|
|
}
|
|
}
|