mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
Fix unit tests
This commit is contained in:
parent
08a885a49d
commit
877bc2469c
|
@ -13,7 +13,7 @@ class MediaWikiParserTest extends MediaWikiTestCase {
|
||||||
$title = Title::newFromText( 'test' );
|
$title = Title::newFromText( 'test' );
|
||||||
$options = new ParserOptions();
|
$options = new ParserOptions();
|
||||||
// Required for MW >= 1.30
|
// Required for MW >= 1.30
|
||||||
if( method_exists ( $options, 'setOption' ) ) {
|
if ( method_exists( $options, 'setOption' ) ) {
|
||||||
$options->setOption( 'wrapclass', false );
|
$options->setOption( 'wrapclass', false );
|
||||||
}
|
}
|
||||||
$this->parser->startExternalParse( $title, $options, 'text', true );
|
$this->parser->startExternalParse( $title, $options, 'text', true );
|
||||||
|
|
|
@ -22,38 +22,18 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
return $DOM->saveXML();
|
return $DOM->saveXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetImageHelper() {
|
|
||||||
$infoboxRenderService = new PortableInfoboxRenderService();
|
|
||||||
|
|
||||||
$reflection = new ReflectionClass( $infoboxRenderService );
|
|
||||||
$reflection_method = $reflection->getMethod( 'getImageHelper' );
|
|
||||||
$reflection_method->setAccessible( true );
|
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
|
||||||
\PortableInfobox\Helpers\PortableInfoboxImagesHelper::class,
|
|
||||||
$reflection_method->invoke( $infoboxRenderService )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers PortableInfoboxRenderService::renderInfobox
|
* @covers PortableInfoboxRenderService::renderInfobox
|
||||||
* @covers PortableInfobox\Helpers\PortableInfoboxTemplateEngine
|
* @covers PortableInfobox\Helpers\PortableInfoboxTemplateEngine
|
||||||
* @param $input
|
* @param $input
|
||||||
* @param $expectedOutput
|
* @param $expectedOutput
|
||||||
* @param $description
|
* @param $description
|
||||||
* @param $mockParams
|
|
||||||
* @param $accentColor
|
* @param $accentColor
|
||||||
* @param $accentColorText
|
* @param $accentColorText
|
||||||
* @dataProvider renderInfoboxDataProvider
|
* @dataProvider renderInfoboxDataProvider
|
||||||
*/
|
*/
|
||||||
public function testRenderInfobox( $input, $expectedOutput, $description, $mockParams, $accentColor, $accentColorText ) {
|
public function testRenderInfobox( $input, $expectedOutput, $description, $accentColor, $accentColorText ) {
|
||||||
$infoboxRenderService = new PortableInfoboxRenderService();
|
$infoboxRenderService = new PortableInfoboxRenderService();
|
||||||
$helper = new DummyPIImageHelper( $mockParams );
|
|
||||||
|
|
||||||
$reflection = new ReflectionClass( $infoboxRenderService );
|
|
||||||
$reflection_property = $reflection->getProperty( 'helper' );
|
|
||||||
$reflection_property->setAccessible( true );
|
|
||||||
$reflection_property->setValue( $infoboxRenderService, $helper );
|
|
||||||
|
|
||||||
$actualOutput = $infoboxRenderService->renderInfobox( $input, '', '', $accentColor, $accentColorText );
|
$actualOutput = $infoboxRenderService->renderInfobox( $input, '', '', $accentColor, $accentColorText );
|
||||||
$expectedHtml = $this->normalizeHTML( $expectedOutput );
|
$expectedHtml = $this->normalizeHTML( $expectedOutput );
|
||||||
|
@ -68,7 +48,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
'input' => [],
|
'input' => [],
|
||||||
'output' => '',
|
'output' => '',
|
||||||
'description' => 'Empty data should yield no infobox markup',
|
'description' => 'Empty data should yield no infobox markup',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -85,7 +64,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
<h2 class="pi-item pi-item-spacing pi-title">Test Title</h2>
|
<h2 class="pi-item pi-item-spacing pi-title">Test Title</h2>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Only title',
|
'description' => 'Only title',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -102,7 +80,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
<h2 class="pi-item pi-item-spacing pi-title" style="background-color:#FFF;color:#000;">Test Title</h2>
|
<h2 class="pi-item pi-item-spacing pi-title" style="background-color:#FFF;color:#000;">Test Title</h2>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Only title with custom colors',
|
'description' => 'Only title with custom colors',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '#FFF',
|
'accentColor' => '#FFF',
|
||||||
'accentColorText' => '#000'
|
'accentColorText' => '#000'
|
||||||
],
|
],
|
||||||
|
@ -114,7 +91,12 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
[
|
[
|
||||||
'alt' => 'image alt',
|
'alt' => 'image alt',
|
||||||
'url' => 'http://image.jpg',
|
'url' => 'http://image.jpg',
|
||||||
'caption' => 'Lorem ipsum dolor'
|
'caption' => 'Lorem ipsum dolor',
|
||||||
|
'width' => '400',
|
||||||
|
'height' => '200',
|
||||||
|
'thumbnail' => 'http://thumbnail.jpg',
|
||||||
|
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
||||||
|
'isImage' => true
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -129,16 +111,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</figure>
|
</figure>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Only image',
|
'description' => 'Only image',
|
||||||
'extendImageData' => [
|
|
||||||
'alt' => 'image alt',
|
|
||||||
'url' => 'http://image.jpg',
|
|
||||||
'caption' => 'Lorem ipsum dolor',
|
|
||||||
'width' => '400',
|
|
||||||
'height' => '200',
|
|
||||||
'thumbnail' => 'http://thumbnail.jpg',
|
|
||||||
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
|
||||||
'isImage' => true
|
|
||||||
],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -150,7 +122,8 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
[
|
[
|
||||||
'alt' => 'image alt',
|
'alt' => 'image alt',
|
||||||
'url' => 'http://image.jpg',
|
'url' => 'http://image.jpg',
|
||||||
'caption' => 'Lorem ipsum dolor'
|
'caption' => 'Lorem ipsum dolor',
|
||||||
|
'isVideo' => true
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -166,12 +139,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</figure>
|
</figure>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Only video',
|
'description' => 'Only video',
|
||||||
'extendImageData' => [
|
|
||||||
'alt' => 'image alt',
|
|
||||||
'url' => 'http://image.jpg',
|
|
||||||
'caption' => 'Lorem ipsum dolor',
|
|
||||||
'isVideo' => true
|
|
||||||
],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -188,7 +155,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
<nav class="pi-navigation pi-item-spacing pi-secondary-background pi-secondary-font">navigation value</nav>
|
<nav class="pi-navigation pi-item-spacing pi-secondary-background pi-secondary-font">navigation value</nav>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'navigation only',
|
'description' => 'navigation only',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -209,7 +175,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</div>
|
</div>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Only pair',
|
'description' => 'Only pair',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -226,7 +191,12 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
'alt' => 'image alt',
|
'alt' => 'image alt',
|
||||||
'url' => 'http://image.jpg'
|
'url' => 'http://image.jpg',
|
||||||
|
'width' => '400',
|
||||||
|
'height' => '200',
|
||||||
|
'thumbnail' => 'http://thumbnail.jpg',
|
||||||
|
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
||||||
|
'isImage' => true
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -252,15 +222,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</div>
|
</div>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Simple infobox with title, image and key-value pair',
|
'description' => 'Simple infobox with title, image and key-value pair',
|
||||||
'extendImageData' => [
|
|
||||||
'alt' => 'image alt',
|
|
||||||
'url' => 'http://image.jpg',
|
|
||||||
'width' => '400',
|
|
||||||
'height' => '200',
|
|
||||||
'thumbnail' => 'http://thumbnail.jpg',
|
|
||||||
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
|
||||||
'isImage' => true
|
|
||||||
],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -292,7 +253,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</div>
|
</div>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Simple infobox with title, INVALID image and key-value pair',
|
'description' => 'Simple infobox with title, INVALID image and key-value pair',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -320,7 +280,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</div>
|
</div>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Simple infobox with title, empty image and key-value pair',
|
'description' => 'Simple infobox with title, empty image and key-value pair',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -378,7 +337,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with title, group with header and two key-value pairs',
|
'description' => 'Infobox with title, group with header and two key-value pairs',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -436,7 +394,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with title, group with header and two key-value pairs, custom accent color and accent text color',
|
'description' => 'Infobox with title, group with header and two key-value pairs, custom accent color and accent text color',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '#FFF',
|
'accentColor' => '#FFF',
|
||||||
'accentColorText' => '#000'
|
'accentColorText' => '#000'
|
||||||
],
|
],
|
||||||
|
@ -498,7 +455,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with horizontal group',
|
'description' => 'Infobox with horizontal group',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -544,7 +500,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with horizontal group without header and labels',
|
'description' => 'Infobox with horizontal group without header and labels',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -563,7 +518,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</nav>
|
</nav>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with navigation',
|
'description' => 'Infobox with navigation',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -614,7 +568,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Horizontal group data without header',
|
'description' => 'Horizontal group data without header',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -671,7 +624,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Horizontal group data with empty label',
|
'description' => 'Horizontal group data with empty label',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -715,7 +667,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Horizontal group data with empty label',
|
'description' => 'Horizontal group data with empty label',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -804,7 +755,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 5 elements with row size 3',
|
'description' => 'Flex wrapped group of 5 elements with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -882,7 +832,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 4 elements with row size 3',
|
'description' => 'Flex wrapped group of 4 elements with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -921,7 +870,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of a single element with row size 3',
|
'description' => 'Flex wrapped group of a single element with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -971,7 +919,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 2 + 1 with row size 3',
|
'description' => 'Flex wrapped group of 2 + 1 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1021,7 +968,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 2 + 1 with row size 7',
|
'description' => 'Flex wrapped group of 2 + 1 with row size 7',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1094,7 +1040,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 2 + 2 + 2 with row size 3',
|
'description' => 'Flex wrapped group of 2 + 2 + 2 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1196,7 +1141,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 1 + 1 + default + 1 + 1 + 1 with row size 3',
|
'description' => 'Flex wrapped group of 1 + 1 + default + 1 + 1 + 1 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1298,7 +1242,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 1 + 1 + 1 + 1 + 1 + default with row size 3',
|
'description' => 'Flex wrapped group of 1 + 1 + 1 + 1 + 1 + default with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1365,7 +1308,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 40 + 1 + 1 with row size 3',
|
'description' => 'Flex wrapped group of 40 + 1 + 1 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1438,7 +1380,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 1 + 40 + 1 with row size 3',
|
'description' => 'Flex wrapped group of 1 + 40 + 1 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1512,7 +1453,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 1 + 1 + title + 1 with row size 3',
|
'description' => 'Flex wrapped group of 1 + 1 + title + 1 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1593,7 +1533,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Flex wrapped group of 1 (no label) + 1 (no label) + title + 1 (no label) + 1 with row size 3',
|
'description' => 'Flex wrapped group of 1 (no label) + 1 (no label) + title + 1 (no label) + 1 with row size 3',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1611,12 +1550,25 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
[
|
[
|
||||||
'alt' => 'image alt',
|
'alt' => 'image alt',
|
||||||
'url' => 'http://image.jpg',
|
'url' => 'http://image.jpg',
|
||||||
'caption' => 'caption'
|
'caption' => 'caption',
|
||||||
|
'ref' => 1,
|
||||||
|
'width' => '400',
|
||||||
|
'height' => '200',
|
||||||
|
'thumbnail' => 'http://thumbnail.jpg',
|
||||||
|
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
||||||
|
'isImage' => true,
|
||||||
|
'isFirst' => true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'alt' => 'image alt',
|
'alt' => 'image alt',
|
||||||
'url' => 'http://image.jpg',
|
'url' => 'http://image.jpg',
|
||||||
'caption' => 'caption'
|
'caption' => 'caption',
|
||||||
|
'ref' => 2,
|
||||||
|
'width' => '400',
|
||||||
|
'height' => '200',
|
||||||
|
'thumbnail' => 'http://thumbnail.jpg',
|
||||||
|
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
||||||
|
'isImage' => true
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -1647,17 +1599,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</div>
|
</div>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Simple infobox with title and image collection',
|
'description' => 'Simple infobox with title and image collection',
|
||||||
'extendImageData' => [
|
|
||||||
'alt' => 'image alt',
|
|
||||||
'url' => 'http://image.jpg',
|
|
||||||
'caption' => 'caption',
|
|
||||||
'ref' => 1,
|
|
||||||
'width' => '400',
|
|
||||||
'height' => '200',
|
|
||||||
'thumbnail' => 'http://thumbnail.jpg',
|
|
||||||
'thumbnail2x' => 'http://thumbnail2x.jpg',
|
|
||||||
'isImage' => true
|
|
||||||
],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1715,7 +1656,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with title, collapsible group with header and two key-value pairs',
|
'description' => 'Infobox with title, collapsible group with header and two key-value pairs',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
],
|
],
|
||||||
|
@ -1773,32 +1713,9 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase {
|
||||||
</section>
|
</section>
|
||||||
</aside>',
|
</aside>',
|
||||||
'description' => 'Infobox with title, collapsed group with header and two key-value pairs',
|
'description' => 'Infobox with title, collapsed group with header and two key-value pairs',
|
||||||
'extendImageData' => [],
|
|
||||||
'accentColor' => '',
|
'accentColor' => '',
|
||||||
'accentColorText' => ''
|
'accentColorText' => ''
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DummyPIImageHelper {
|
|
||||||
private $imageData = [];
|
|
||||||
private $ref = 1;
|
|
||||||
|
|
||||||
public function __construct( $imageData = [] ) {
|
|
||||||
$this->imageData = $imageData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function extendImageData( $imageData ) {
|
|
||||||
$data = $this->imageData;
|
|
||||||
$data['ref'] = $this->ref++;
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function extendImageCollectionData( $images ) {
|
|
||||||
$images[0]['isFirst'] = true;
|
|
||||||
return [
|
|
||||||
'images' => $images
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ use PortableInfobox\Helpers\PortableInfoboxImagesHelper;
|
||||||
*/
|
*/
|
||||||
class PortableInfoboxImagesHelperTest extends MediaWikiTestCase {
|
class PortableInfoboxImagesHelperTest extends MediaWikiTestCase {
|
||||||
private $helper;
|
private $helper;
|
||||||
private static $testCustomWidthLogicCount;
|
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -92,17 +91,11 @@ class PortableInfoboxImagesHelperTest extends MediaWikiTestCase {
|
||||||
* @dataProvider customWidthProvider
|
* @dataProvider customWidthProvider
|
||||||
*/
|
*/
|
||||||
public function testCustomWidthLogic( $customWidth, $preferredWidth, $resultDimensions, $thumbnailDimensions, $thumbnail2xDimensions, $originalDimension ) {
|
public function testCustomWidthLogic( $customWidth, $preferredWidth, $resultDimensions, $thumbnailDimensions, $thumbnail2xDimensions, $originalDimension ) {
|
||||||
self::$testCustomWidthLogicCount++;
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'name' => 'test',
|
|
||||||
'ref' => self::$testCustomWidthLogicCount,
|
|
||||||
'thumbnail' => null,
|
'thumbnail' => null,
|
||||||
'thumbnail2x' => null,
|
'thumbnail2x' => null,
|
||||||
'width' => $resultDimensions['width'],
|
'width' => $resultDimensions['width'],
|
||||||
'height' => $resultDimensions['height'],
|
'height' => $resultDimensions['height']
|
||||||
'isImage' => true,
|
|
||||||
'isVideo' => false,
|
|
||||||
'isAudio' => false
|
|
||||||
];
|
];
|
||||||
$thumb = $this->getMockBuilder( 'ThumbnailImage' )
|
$thumb = $this->getMockBuilder( 'ThumbnailImage' )
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -115,22 +108,17 @@ class PortableInfoboxImagesHelperTest extends MediaWikiTestCase {
|
||||||
$file->expects( $this->once() )->method( 'exists' )->will( $this->returnValue( true ) );
|
$file->expects( $this->once() )->method( 'exists' )->will( $this->returnValue( true ) );
|
||||||
$file->expects( $this->once() )->method( 'getWidth' )->will( $this->returnValue( $originalDimension['width'] ) );
|
$file->expects( $this->once() )->method( 'getWidth' )->will( $this->returnValue( $originalDimension['width'] ) );
|
||||||
$file->expects( $this->once() )->method( 'getHeight' )->will( $this->returnValue( $originalDimension['height'] ) );
|
$file->expects( $this->once() )->method( 'getHeight' )->will( $this->returnValue( $originalDimension['height'] ) );
|
||||||
$file->expects( $this->any() )->method( 'getMediaType' )->will( $this->returnValue( MEDIATYPE_BITMAP ) );
|
$file->expects( $this->once() )->method( 'getMediaType' )->will( $this->returnValue( MEDIATYPE_BITMAP ) );
|
||||||
|
|
||||||
$file->expects( $this->any() )
|
$file->expects( $this->any() )
|
||||||
->method( 'transform' )
|
->method( 'transform' )
|
||||||
->with( $this->logicalOr( $this->equalTo( $thumbnailDimensions ), $this->equalTo( $thumbnail2xDimensions ) ) )
|
->with( $this->logicalOr( $this->equalTo( $thumbnailDimensions ), $this->equalTo( $thumbnail2xDimensions ) ) )
|
||||||
->will( $this->returnValue( $thumb ) );
|
->will( $this->returnValue( $thumb ) );
|
||||||
|
|
||||||
$helper = $this->getMock( PortableInfoboxImagesHelper::class, [ 'getFileFromTitle' ] );
|
|
||||||
$helper->expects( $this->any() )
|
|
||||||
->method( 'getFileFromTitle' )
|
|
||||||
->will( $this->returnValue( $file ) );
|
|
||||||
|
|
||||||
global $wgPortableInfoboxCustomImageWidth;
|
global $wgPortableInfoboxCustomImageWidth;
|
||||||
$wgPortableInfoboxCustomImageWidth = $customWidth;
|
$wgPortableInfoboxCustomImageWidth = $customWidth;
|
||||||
|
|
||||||
$result = $helper->extendImageData( [ 'name' => 'test' ], $preferredWidth );
|
$result = $this->helper->extendImageData( $file, $preferredWidth );
|
||||||
|
|
||||||
$this->assertEquals( $expected, $result );
|
$this->assertEquals( $expected, $result );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use PortableInfobox\Helpers\PortableInfoboxDataBag;
|
use PortableInfobox\Helpers\PortableInfoboxDataBag;
|
||||||
|
use PortableInfobox\Helpers\PortableInfoboxImagesHelper;
|
||||||
|
use PortableInfobox\Parser\Nodes\NodeFactory;
|
||||||
use PortableInfobox\Parser\Nodes\NodeMedia;
|
use PortableInfobox\Parser\Nodes\NodeMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,13 +11,6 @@ use PortableInfobox\Parser\Nodes\NodeMedia;
|
||||||
*/
|
*/
|
||||||
class NodeMediaTest extends MediaWikiTestCase {
|
class NodeMediaTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
protected function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
global $wgUseInstantCommons;
|
|
||||||
$wgUseInstantCommons = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers PortableInfobox\Parser\Nodes\NodeMedia::getGalleryData
|
* @covers PortableInfobox\Parser\Nodes\NodeMedia::getGalleryData
|
||||||
* @covers PortableInfobox\Helpers\PortableInfoboxDataBag
|
* @covers PortableInfobox\Helpers\PortableInfoboxDataBag
|
||||||
|
@ -139,18 +134,27 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
*
|
*
|
||||||
* @param $markup
|
* @param $markup
|
||||||
* @param $params
|
* @param $params
|
||||||
|
* @param $mediaType
|
||||||
* @param $expected
|
* @param $expected
|
||||||
*/
|
*/
|
||||||
public function testData( $markup, $params, $expected ) {
|
public function testData( $markup, $params, $mediaType, $expected ) {
|
||||||
$imageMock = empty( $params ) ? null : new ImageMock();
|
$fileMock = is_null( $mediaType ) ? null : new FileMock( $mediaType );
|
||||||
$xmlObj = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
$node = NodeFactory::newFromXML( $markup, $params );
|
||||||
|
|
||||||
$mock = $this->getMock( NodeMedia::class, [ 'getFilefromTitle' ], [ $xmlObj, $params ] );
|
$helper = $this->getMock( PortableInfoboxImagesHelper::class, [ 'getFile', 'extendImageData' ] );
|
||||||
$mock->expects( $this->any() )
|
$helper->expects( $this->any() )
|
||||||
->method( 'getFilefromTitle' )
|
->method( 'getFile' )
|
||||||
->willReturn( $imageMock );
|
->willReturn( $fileMock );
|
||||||
|
$helper->expects( $this->any() )
|
||||||
|
->method( 'extendImageData' )
|
||||||
|
->willReturn( [] );
|
||||||
|
|
||||||
$this->assertEquals( $expected, $mock->getData() );
|
$reflection = new ReflectionClass( $node );
|
||||||
|
$reflectionProperty = $reflection->getProperty( 'helper' );
|
||||||
|
$reflectionProperty->setAccessible( true );
|
||||||
|
$reflectionProperty->setValue( $node, $helper );
|
||||||
|
|
||||||
|
$this->assertEquals( $expected, $node->getData() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataProvider() {
|
public function dataProvider() {
|
||||||
|
@ -159,28 +163,105 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
[
|
[
|
||||||
'<media source="img"></media>',
|
'<media source="img"></media>',
|
||||||
[],
|
[],
|
||||||
|
null,
|
||||||
[ [] ]
|
[ [] ]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'<media source="img"></media>',
|
'<media source="img"></media>',
|
||||||
[ 'img' => 'test.jpg' ],
|
[ 'img' => 'test.jpg' ],
|
||||||
[ [ 'url' => '', 'name' => 'Test.jpg', 'alt' => 'Test.jpg', 'caption' => null ] ]
|
MEDIATYPE_BITMAP,
|
||||||
|
[ [
|
||||||
|
'url' => 'http://test.url',
|
||||||
|
'name' => 'Test.jpg',
|
||||||
|
'alt' => 'Test.jpg',
|
||||||
|
'caption' => null,
|
||||||
|
'isImage' => true,
|
||||||
|
'isVideo' => false,
|
||||||
|
'isAudio' => false
|
||||||
|
] ]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'<media source="img"><alt><default>test alt</default></alt></media>',
|
'<media source="img"><alt><default>test alt</default></alt></media>',
|
||||||
[ 'img' => 'test.jpg' ],
|
[ 'img' => 'test.jpg' ],
|
||||||
[ [ 'url' => '', 'name' => 'Test.jpg', 'alt' => 'test alt', 'caption' => null ] ]
|
MEDIATYPE_BITMAP,
|
||||||
|
[ [
|
||||||
|
'url' => 'http://test.url',
|
||||||
|
'name' => 'Test.jpg',
|
||||||
|
'alt' => 'test alt',
|
||||||
|
'caption' => null,
|
||||||
|
'isImage' => true,
|
||||||
|
'isVideo' => false,
|
||||||
|
'isAudio' => false
|
||||||
|
] ]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'<media source="img"><alt source="alt source"><default>test alt</default></alt></media>',
|
'<media source="img"><alt source="alt source"><default>test alt</default></alt></media>',
|
||||||
[ 'img' => 'test.jpg', 'alt source' => 2 ],
|
[ 'img' => 'test.jpg', 'alt source' => 2 ],
|
||||||
[ [ 'url' => '', 'name' => 'Test.jpg', 'alt' => 2, 'caption' => null ] ]
|
MEDIATYPE_BITMAP,
|
||||||
|
[ [
|
||||||
|
'url' => 'http://test.url',
|
||||||
|
'name' => 'Test.jpg',
|
||||||
|
'alt' => 2,
|
||||||
|
'caption' => null,
|
||||||
|
'isImage' => true,
|
||||||
|
'isVideo' => false,
|
||||||
|
'isAudio' => false
|
||||||
|
] ]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'<media source="img"><alt><default>test alt</default></alt><caption source="img"/></media>',
|
'<media source="img"><alt><default>test alt</default></alt><caption source="img"/></media>',
|
||||||
[ 'img' => 'test.jpg' ],
|
[ 'img' => 'test.jpg' ],
|
||||||
[ [ 'url' => '', 'name' => 'Test.jpg', 'alt' => 'test alt', 'caption' => 'test.jpg' ] ]
|
MEDIATYPE_BITMAP,
|
||||||
|
[ [
|
||||||
|
'url' => 'http://test.url',
|
||||||
|
'name' => 'Test.jpg',
|
||||||
|
'alt' => 'test alt',
|
||||||
|
'caption' => 'test.jpg',
|
||||||
|
'isImage' => true,
|
||||||
|
'isVideo' => false,
|
||||||
|
'isAudio' => false
|
||||||
|
] ]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'<media source="media" />',
|
||||||
|
[ 'media' => 'test.webm' ],
|
||||||
|
MEDIATYPE_VIDEO,
|
||||||
|
[ [
|
||||||
|
'url' => 'http://test.url',
|
||||||
|
'name' => 'Test.webm',
|
||||||
|
'alt' => 'Test.webm',
|
||||||
|
'caption' => null,
|
||||||
|
'isImage' => false,
|
||||||
|
'isVideo' => true,
|
||||||
|
'isAudio' => false
|
||||||
|
] ]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<media source="media" video="false" />',
|
||||||
|
[ 'media' => 'test.webm' ],
|
||||||
|
MEDIATYPE_VIDEO,
|
||||||
|
[ [] ]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<media source="media" />',
|
||||||
|
[ 'media' => 'test.ogg' ],
|
||||||
|
MEDIATYPE_AUDIO,
|
||||||
|
[ [
|
||||||
|
'url' => 'http://test.url',
|
||||||
|
'name' => 'Test.ogg',
|
||||||
|
'alt' => 'Test.ogg',
|
||||||
|
'caption' => null,
|
||||||
|
'isImage' => false,
|
||||||
|
'isVideo' => false,
|
||||||
|
'isAudio' => true
|
||||||
|
] ]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'<media source="media" audio="false" />',
|
||||||
|
[ 'media' => 'test.ogg' ],
|
||||||
|
MEDIATYPE_AUDIO,
|
||||||
|
[ [] ]
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +274,7 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
* @param $expected
|
* @param $expected
|
||||||
*/
|
*/
|
||||||
public function testIsEmpty( $markup, $params, $expected ) {
|
public function testIsEmpty( $markup, $params, $expected ) {
|
||||||
$node = PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, $params );
|
$node = NodeFactory::newFromXML( $markup, $params );
|
||||||
|
|
||||||
$this->assertEquals( $expected, $node->isEmpty() );
|
$this->assertEquals( $expected, $node->isEmpty() );
|
||||||
}
|
}
|
||||||
|
@ -212,7 +293,7 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
* @param $expected
|
* @param $expected
|
||||||
*/
|
*/
|
||||||
public function testSources( $markup, $expected ) {
|
public function testSources( $markup, $expected ) {
|
||||||
$node = PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, [] );
|
$node = NodeFactory::newFromXML( $markup, [] );
|
||||||
|
|
||||||
$this->assertEquals( $expected, $node->getSources() );
|
$this->assertEquals( $expected, $node->getSources() );
|
||||||
}
|
}
|
||||||
|
@ -247,7 +328,7 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
/** @dataProvider metadataProvider */
|
/** @dataProvider metadataProvider */
|
||||||
public function testMetadata( $markup, $expected ) {
|
public function testMetadata( $markup, $expected ) {
|
||||||
$node = PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, [] );
|
$node = NodeFactory::newFromXML( $markup, [] );
|
||||||
|
|
||||||
$this->assertEquals( $expected, $node->getMetadata() );
|
$this->assertEquals( $expected, $node->getMetadata() );
|
||||||
}
|
}
|
||||||
|
@ -265,88 +346,6 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider videoProvider
|
|
||||||
* @param $markup
|
|
||||||
* @param $params
|
|
||||||
* @param $expected
|
|
||||||
* @throws PortableInfobox\Parser\XmlMarkupParseErrorException
|
|
||||||
*/
|
|
||||||
public function testVideo( $markup, $params, $expected ) {
|
|
||||||
$videoMock = new VideoMock();
|
|
||||||
$xmlObj = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
|
||||||
|
|
||||||
$mock = $this->getMock( NodeMedia::class, [ 'getFilefromTitle' ], [ $xmlObj, $params ] );
|
|
||||||
$mock->expects( $this->any() )
|
|
||||||
->method( 'getFilefromTitle' )
|
|
||||||
->willReturn( $videoMock );
|
|
||||||
|
|
||||||
$this->assertEquals( $expected, $mock->getData() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function videoProvider() {
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'<media source="media" />',
|
|
||||||
[ 'media' => 'test.webm' ],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'url' => 'http://test.url',
|
|
||||||
'name' => 'Test.webm',
|
|
||||||
'alt' => 'Test.webm',
|
|
||||||
'caption' => null
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'<media source="media" video="false" />',
|
|
||||||
[ 'media' => 'test.webm' ],
|
|
||||||
[ [] ]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider audioProvider
|
|
||||||
* @param $markup
|
|
||||||
* @param $params
|
|
||||||
* @param $expected
|
|
||||||
* @throws PortableInfobox\Parser\XmlMarkupParseErrorException
|
|
||||||
*/
|
|
||||||
public function testAudio( $markup, $params, $expected ) {
|
|
||||||
$audioMock = new AudioMock();
|
|
||||||
$xmlObj = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
|
||||||
|
|
||||||
$mock = $this->getMock( NodeMedia::class, [ 'getFilefromTitle' ], [ $xmlObj, $params ] );
|
|
||||||
$mock->expects( $this->any() )
|
|
||||||
->method( 'getFilefromTitle' )
|
|
||||||
->willReturn( $audioMock );
|
|
||||||
|
|
||||||
$this->assertEquals( $expected, $mock->getData() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function audioProvider() {
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'<media source="media" />',
|
|
||||||
[ 'media' => 'test.ogg' ],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'url' => 'http://test.url',
|
|
||||||
'name' => 'Test.ogg',
|
|
||||||
'alt' => 'Test.ogg',
|
|
||||||
'caption' => null
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'<media source="media" audio="false" />',
|
|
||||||
[ 'media' => 'test.ogg' ],
|
|
||||||
[ [] ]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers PortableInfobox\Parser\Nodes\NodeMedia::isTypeAllowed
|
* @covers PortableInfobox\Parser\Nodes\NodeMedia::isTypeAllowed
|
||||||
* @covers PortableInfobox\Parser\Nodes\NodeAudio
|
* @covers PortableInfobox\Parser\Nodes\NodeAudio
|
||||||
|
@ -413,29 +412,15 @@ class NodeMediaTest extends MediaWikiTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageMock {
|
class FileMock {
|
||||||
|
protected $mediaType;
|
||||||
|
|
||||||
|
public function __construct( $mediaType ) {
|
||||||
|
$this->mediaType = $mediaType;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMediaType() {
|
public function getMediaType() {
|
||||||
return MEDIATYPE_BITMAP;
|
return $this->mediaType;
|
||||||
}
|
|
||||||
|
|
||||||
public function getUrl() {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class VideoMock {
|
|
||||||
public function getMediaType() {
|
|
||||||
return MEDIATYPE_VIDEO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUrl() {
|
|
||||||
return 'http://test.url';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AudioMock {
|
|
||||||
public function getMediaType() {
|
|
||||||
return MEDIATYPE_AUDIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrl() {
|
public function getUrl() {
|
||||||
|
|
Loading…
Reference in a new issue