From 3007c92c62d9b8b6c0bc2443cbb97daaa3c9e8c3 Mon Sep 17 00:00:00 2001 From: Luqgreg Date: Sun, 12 Aug 2018 17:50:16 +0200 Subject: [PATCH] Fix unit tests --- .../PortableInfoboxRenderServiceTest.php | 198 +----------------- .../PortableInfoboxImagesHelperTest.php | 5 +- .../{NodeImageTest.php => NodeMediaTest.php} | 160 ++++++++++---- 3 files changed, 128 insertions(+), 235 deletions(-) rename tests/phpunit/nodes/{NodeImageTest.php => NodeMediaTest.php} (57%) diff --git a/tests/phpunit/PortableInfoboxRenderServiceTest.php b/tests/phpunit/PortableInfoboxRenderServiceTest.php index 251d587..a4d437c 100644 --- a/tests/phpunit/PortableInfoboxRenderServiceTest.php +++ b/tests/phpunit/PortableInfoboxRenderServiceTest.php @@ -22,170 +22,6 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase { return $DOM->saveXML(); } - /** - * @param $data - * @param $expected - * - * @dataProvider filterImagesDataProvider - */ - public function testFilterImages( $data, $expected ) { - $method = ( new ReflectionClass( 'PortableInfoboxRenderService' ) )->getMethod( 'filterImageData' ); - $method->setAccessible( true ); - - $renderService = new PortableInfoboxRenderService(); - - $this->assertEquals( $expected, $method->invokeArgs( $renderService, [ $data ] ) ); - } - - public function filterImagesDataProvider() { - return [ - [ - 'data' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => 'caption1', - 'isVideo' => false, - ], - [ - 'url' => 'some.url.com', - 'name' => 'name2', - 'key' => 'key2', - 'alt' => 'alt2', - 'caption' => 'caption2', - 'isVideo' => false, - ], - ], - 'expected' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => 'caption1', - 'isVideo' => false, - ], - [ - 'url' => 'some.url.com', - 'name' => 'name2', - 'key' => 'key2', - 'alt' => 'alt2', - 'caption' => 'caption2', - 'isVideo' => false, - ], - ] - ], - [ - 'data' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => '', - 'isVideo' => false, - ], - [ - 'url' => 'some.url.com', - 'name' => 'name2', - 'key' => 'key2', - 'alt' => 'alt2', - 'caption' => 'caption2', - 'isVideo' => false, - ], - [ - 'url' => 'some.url.com', - 'name' => 'name3', - 'key' => 'key3', - 'alt' => 'alt3', - 'caption' => 'caption3', - 'isVideo' => false, - ], - ], - 'expected' => [ - 1 => [ - 'url' => 'some.url.com', - 'name' => 'name2', - 'key' => 'key2', - 'alt' => 'alt2', - 'caption' => 'caption2', - 'isVideo' => false, - ], - 2 => [ - 'url' => 'some.url.com', - 'name' => 'name3', - 'key' => 'key3', - 'alt' => 'alt3', - 'caption' => 'caption3', - 'isVideo' => false, - ] - ] - ], - [ - 'data' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => 'caption1', - 'isVideo' => false, - ], - [ - 'url' => 'some.url.com', - 'name' => 'name2', - 'key' => 'key2', - 'alt' => 'alt2', - 'caption' => '', - 'isVideo' => false, - ], - ], - 'expected' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => 'caption1', - 'isVideo' => false, - ], - ], - ], - [ - 'data' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => '', - 'isVideo' => false, - ], - [ - 'url' => 'some.url.com', - 'name' => 'name2', - 'key' => 'key2', - 'alt' => 'alt2', - 'caption' => '', - 'isVideo' => false, - ], - ], - 'expected' => [ - [ - 'url' => 'some.url.com', - 'name' => 'name1', - 'key' => 'key1', - 'alt' => 'alt1', - 'caption' => '', - 'isVideo' => false, - ], - ] - ], - ]; - } - /** * @param $input * @param $expectedOutput @@ -263,16 +99,13 @@ class PortableInfoboxRenderServiceTest extends MediaWikiTestCase { [ 'alt' => 'image alt', 'url' => 'http://image.jpg', - 'name' => 'image', - 'key' => 'image', - 'caption' => 'Lorem ipsum dolor', - 'isVideo' => false + 'caption' => 'Lorem ipsum dolor' ] ] ] ], 'output' => '