2015-04-27 14:05:31 +00:00
< ? php
2015-07-01 16:03:57 +00:00
class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
2015-07-29 11:51:55 +00:00
//todo: https://wikia-inc.atlassian.net/browse/DAT-3076
//todo: we are testing a lot of functionality and have issues with mocking
//todo: we should move all render service test to API tests
2015-05-04 14:43:53 +00:00
protected function setUp () {
$this -> setupFile = dirname ( __FILE__ ) . '/../PortableInfobox.setup.php' ;
2015-04-27 14:05:31 +00:00
parent :: setUp ();
2015-07-10 11:19:08 +00:00
}
2015-04-27 14:05:31 +00:00
2015-07-10 12:31:43 +00:00
/**
2015-07-21 12:30:13 +00:00
* @ param $input to check presence of some additional config fields . Possible fields :
* 'isInvalidImage' - bool - if getThumbnail should return false
2016-04-04 13:50:36 +00:00
* 'isMobile' - bool - if we want to test mobile env
* 'isMercury' - bool - if we want to test Mercury skin
* 'isMercuryExperimentalMarkupEnabled' - bool
2015-07-21 12:30:13 +00:00
* 'smallImageDimensions' - integer - size of small image ( both width and height )
2015-07-22 13:28:39 +00:00
*
2015-07-10 12:31:43 +00:00
* @ return PHPUnit_Framework_MockObject_MockObject
2015-07-10 14:57:57 +00:00
*/
2015-07-29 08:58:39 +00:00
private function mockInfoboxRenderServiceHelper ( $input ) {
$isValidHeroDataItem = isset ( $input [ 'isValidHeroDataItem' ] ) && $input [ 'isValidHeroDataItem' ];
2016-04-04 13:50:36 +00:00
$isMobile = isset ( $input [ 'isMobile' ] ) && $input [ 'isMobile' ];
$isMercury = isset ( $input [ 'isMercury' ] ) && $input [ 'isMercury' ];
2015-07-29 08:58:39 +00:00
$createHorizontalGroupData = isset ( $input [ 'createHorizontalGroupData' ] ) ?
$input [ 'createHorizontalGroupData' ] : null ;
$extendImageData = isset ( $input [ 'extendImageData' ] ) ? $input [ 'extendImageData' ] : null ;
2015-07-22 13:28:39 +00:00
2015-07-29 08:58:39 +00:00
$mock = $this -> getMockBuilder ( 'Wikia\PortableInfobox\Helpers\PortableInfoboxRenderServiceHelper' )
2016-04-04 13:50:36 +00:00
-> setMethods ( [ 'isValidHeroDataItem' , 'validateType' , 'isMobile' , 'isMercury' ,
'isMercuryExperimentalMarkupEnabled' , 'createHorizontalGroupData' , 'extendImageData' ] )
2015-07-10 12:10:03 +00:00
-> getMock ();
2015-07-29 08:58:39 +00:00
$mock -> expects ( $this -> any () )
-> method ( 'isValidHeroDataItem' )
-> will ( $this -> returnValue ( $isValidHeroDataItem ) );
$mock -> expects ( $this -> any () )
-> method ( 'validateType' )
-> will ( $this -> returnValue ( true ) );
2015-07-10 12:10:03 +00:00
$mock -> expects ( $this -> any () )
2016-04-04 13:50:36 +00:00
-> method ( 'isMobile' )
-> will ( $this -> returnValue ( $isMobile ) );
$mock -> expects ( $this -> any () )
-> method ( 'isMercury' )
-> will ( $this -> returnValue ( $isMercury ) );
2015-07-10 12:10:03 +00:00
$mock -> expects ( $this -> any () )
2015-07-29 08:58:39 +00:00
-> method ( 'createHorizontalGroupData' )
-> will ( $this -> returnValue ( $createHorizontalGroupData ) );
2015-07-20 09:52:32 +00:00
$mock -> expects ( $this -> any () )
2015-07-29 08:58:39 +00:00
-> method ( 'extendImageData' )
-> will ( $this -> returnValue ( $extendImageData ) );
2015-04-27 14:05:31 +00:00
2015-07-29 08:58:39 +00:00
$this -> mockClass ( 'Wikia\PortableInfobox\Helpers\PortableInfoboxRenderServiceHelper' , $mock );
2015-05-20 11:56:56 +00:00
}
2015-04-27 14:05:31 +00:00
2015-07-13 08:56:19 +00:00
/**
* @ param $html
* @ return string
2015-07-22 13:28:39 +00:00
*/
2015-07-13 08:56:19 +00:00
private function normalizeHTML ( $html ) {
2016-03-29 10:57:07 +00:00
$DOM = new DOMDocument ( '1.0' );
2015-07-10 14:57:57 +00:00
$DOM -> formatOutput = true ;
$DOM -> preserveWhiteSpace = false ;
2015-07-13 08:56:19 +00:00
$DOM -> loadXML ( $html );
2015-05-04 14:16:35 +00:00
2015-07-10 14:57:57 +00:00
return $DOM -> saveXML ();
2015-04-27 14:05:31 +00:00
}
2016-03-29 10:57:07 +00:00
public function testEuropaThemeEnabled () {
$wrapper = new \Wikia\Util\GlobalStateWrapper ( [ 'wgEnablePortableInfoboxEuropaTheme' => true ] );
$infoboxRenderService = new PortableInfoboxRenderService ();
$output = $wrapper -> wrap ( function () use ( $infoboxRenderService ) {
return $infoboxRenderService -> renderInfobox (
[ [ 'type' => 'title' , 'data' => [ 'value' => 'Test' ] ] ], '' , '' );
} );
$expected = $this -> normalizeHTML ( ' < aside class = " portable-infobox pi-background pi-europa " >
< h2 class = " pi-item pi-item-spacing pi-title " > Test </ h2 >
</ aside > ' );
$result = $this -> normalizeHTML ( $output );
$this -> assertEquals ( $expected , $result );
}
2015-05-20 11:56:56 +00:00
/**
* @ param $input
* @ param $expectedOutput
* @ param $description
2015-11-03 16:19:29 +00:00
* @ param $mockParams
2015-07-10 14:57:57 +00:00
* @ dataProvider testRenderInfoboxDataProvider
2015-05-20 11:56:56 +00:00
*/
2015-07-29 08:58:39 +00:00
public function testRenderInfobox ( $input , $expectedOutput , $description , $mockParams ) {
$this -> mockInfoboxRenderServiceHelper ( $mockParams );
$infoboxRenderService = new PortableInfoboxRenderService ();
2015-11-05 13:21:20 +00:00
$actualOutput = $infoboxRenderService -> renderInfobox ( $input , '' , '' );
2016-03-29 10:57:07 +00:00
$expectedHtml = $this -> normalizeHTML ( $expectedOutput );
2015-07-13 08:56:19 +00:00
$actualHtml = $this -> normalizeHTML ( $actualOutput );
2015-05-20 11:56:56 +00:00
$this -> assertEquals ( $expectedHtml , $actualHtml , $description );
}
2015-04-27 14:05:31 +00:00
public function testRenderInfoboxDataProvider () {
2015-07-01 14:34:34 +00:00
return [
[
2016-03-29 10:57:07 +00:00
'input' => [ ],
2015-04-27 14:05:31 +00:00
'output' => '' ,
'description' => 'Empty data should yield no infobox markup'
2015-07-01 16:03:57 +00:00
],
[
'input' => [
[
'type' => 'title' ,
'data' => [
'value' => 'Test Title'
]
2015-04-27 14:05:31 +00:00
]
2015-07-01 16:03:57 +00:00
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< h2 class = " pi-item pi-item-spacing pi-title " > Test Title </ h2 >
2015-07-01 16:03:57 +00:00
</ aside > ' ,
2015-04-27 14:05:31 +00:00
'description' => 'Only title'
2015-07-01 16:03:57 +00:00
],
[
'input' => [
[
'type' => 'image' ,
'data' => [
2015-10-16 01:15:52 +00:00
[
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'name' => 'image' ,
'key' => 'image' ,
'caption' => 'Lorem ipsum dolor' ,
'isVideo' => false
]
2015-07-01 16:03:57 +00:00
]
2015-05-20 11:56:56 +00:00
]
2015-07-01 16:03:57 +00:00
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< figure class = " pi-item pi-image " >
< a href = " http://image.jpg " class = " image image-thumbnail " title = " image alt " >
< img src = " http://thumbnail.jpg " class = " pi-image-thumbnail " alt = " image alt "
width = " 400 " height = " 200 " data - image - key = " image " data - image - name = " image " />
</ a >
< figcaption class = " pi-item-spacing pi-caption " > Lorem ipsum dolor </ figcaption >
</ figure >
2015-07-01 16:03:57 +00:00
</ aside > ' ,
2015-07-29 08:58:39 +00:00
'description' => 'Only image' ,
'mockParams' => [
'extendImageData' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'caption' => 'Lorem ipsum dolor' ,
'name' => 'image' ,
'key' => 'image' ,
'width' => '400' ,
'height' => '200' ,
2015-07-29 13:22:28 +00:00
'thumbnail' => 'http://thumbnail.jpg' ,
'media-type' => 'image' ,
'isVideo' => false
]
]
],
[
'input' => [
[
'type' => 'image' ,
'data' => [
2015-10-16 01:15:52 +00:00
[
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'caption' => 'Lorem ipsum dolor' ,
'isVideo' => true ,
'duration' => '1:20' ,
'name' => 'test' ,
'key' => 'test'
]
2015-07-29 13:22:28 +00:00
]
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< figure class = " pi-item pi-image " >
< a href = " http://image.jpg "
class = " image image-thumbnail video video-thumbnail small "
title = " image alt " >
< img src = " http://thumbnail.jpg " class = " pi-image-thumbnail "
alt = " image alt " width = " 400 " height = " 200 " data - video - key = " image "
data - video - name = " image " />
< span class = " duration " itemprop = " duration " > 1 : 20 </ span >
< span class = " play-circle " ></ span >
</ a >
< figcaption class = " pi-item-spacing pi-caption " > Lorem ipsum dolor </ figcaption >
</ figure >
2015-07-29 13:22:28 +00:00
</ aside > ' ,
'description' => 'Only video' ,
'mockParams' => [
'extendImageData' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'caption' => 'Lorem ipsum dolor' ,
'name' => 'image' ,
'key' => 'image' ,
'width' => '400' ,
'height' => '200' ,
'thumbnail' => 'http://thumbnail.jpg' ,
'media-type' => 'video' ,
'isVideo' => true ,
'duration' => '1:20'
2015-07-29 08:58:39 +00:00
]
]
2015-07-01 16:03:57 +00:00
],
[
'input' => [
[
2015-07-01 14:19:31 +00:00
'type' => 'navigation' ,
2015-07-01 16:03:57 +00:00
'data' => [
2015-07-01 14:19:31 +00:00
'value' => 'navigation value' ,
2015-07-01 16:03:57 +00:00
]
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< nav class = " pi-navigation pi-item-spacing pi-secondary-background pi-secondary-font " > navigation value </ nav >
2015-07-01 16:03:57 +00:00
</ aside > ' ,
2015-07-01 14:19:31 +00:00
'description' => 'navigation only'
2015-07-01 16:03:57 +00:00
],
[
'input' => [
[
'type' => 'data' ,
'data' => [
'label' => 'test label' ,
'value' => 'test value'
]
2015-05-04 14:30:40 +00:00
]
2015-07-01 16:03:57 +00:00
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
2015-07-31 12:54:10 +00:00
< div class = " pi-item pi-data pi-item-spacing pi-border-color " >
2015-07-29 15:40:21 +00:00
< h3 class = " pi-data-label pi-secondary-font " > test label </ h3 >
< div class = " pi-data-value pi-font " > test value </ div >
2015-07-01 16:03:57 +00:00
</ div >
</ aside > ' ,
2015-05-04 14:30:40 +00:00
'description' => 'Only pair'
2015-07-01 16:03:57 +00:00
],
[
'input' => [
[
'type' => 'title' ,
'data' => [
'value' => 'Test Title'
]
],
[
'type' => 'image' ,
'data' => [
2015-10-16 01:15:52 +00:00
[
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'name' => 'image' ,
'key' => 'image' ,
'isVideo' => false
]
2015-07-01 16:03:57 +00:00
]
],
[
'type' => 'data' ,
'data' => [
'label' => 'test label' ,
'value' => 'test value'
]
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< h2 class = " pi-item pi-item-spacing pi-title " > Test Title </ h2 >
< figure class = " pi-item pi-image " >
< a href = " http://image.jpg " class = " image image-thumbnail " title = " image alt " >
< img src = " http://thumbnail.jpg " class = " pi-image-thumbnail " alt = " image alt "
width = " 400 " height = " 200 " data - image - key = " image " data - image - name = " image " />
</ a >
</ figure >
2015-07-31 12:54:10 +00:00
< div class = " pi-item pi-data pi-item-spacing pi-border-color " >
2015-07-29 15:40:21 +00:00
< h3 class = " pi-data-label pi-secondary-font " > test label </ h3 >
< div class = " pi-data-value pi-font " > test value </ div >
2015-05-07 12:36:30 +00:00
</ div >
</ aside > ' ,
2015-07-29 08:58:39 +00:00
'description' => 'Simple infobox with title, image and key-value pair' ,
'mockParams' => [
'extendImageData' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'name' => 'image' ,
'key' => 'image' ,
'width' => '400' ,
'height' => '200' ,
2015-07-29 13:22:28 +00:00
'thumbnail' => 'http://thumbnail.jpg' ,
'media-type' => 'image' ,
'isVideo' => false
2015-07-21 11:33:24 +00:00
]
2015-07-29 08:58:39 +00:00
]
2015-07-21 11:33:24 +00:00
],
2015-04-27 14:05:31 +00:00
[
'input' => [
[
'type' => 'title' ,
'data' => [
'value' => 'Test Title'
2015-05-07 13:25:26 +00:00
]
2015-04-27 14:05:31 +00:00
],
[
'type' => 'image' ,
2016-03-29 10:57:07 +00:00
'data' => [ ]
2015-04-27 14:05:31 +00:00
],
[
2015-05-04 10:48:57 +00:00
'type' => 'data' ,
2015-04-27 14:05:31 +00:00
'data' => [
'label' => 'test label' ,
'value' => 'test value'
2015-05-07 13:25:26 +00:00
]
2015-04-27 14:05:31 +00:00
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< h2 class = " pi-item pi-item-spacing pi-title " > Test Title </ h2 >
2015-07-31 12:54:10 +00:00
< div class = " pi-item pi-data pi-item-spacing pi-border-color " >
2015-07-29 15:40:21 +00:00
< h3 class = " pi-data-label pi-secondary-font " > test label </ h3 >
< div class = " pi-data-value pi-font " > test value </ div >
2015-05-07 12:36:30 +00:00
</ div >
</ aside > ' ,
2015-07-10 12:10:03 +00:00
'description' => 'Simple infobox with title, INVALID image and key-value pair'
2015-04-27 14:05:31 +00:00
],
[
'input' => [
[
'type' => 'title' ,
'data' => [
'value' => 'Test Title'
2015-05-07 13:25:26 +00:00
]
2015-04-27 14:05:31 +00:00
],
[
2015-05-04 10:48:57 +00:00
'type' => 'data' ,
2015-04-27 14:05:31 +00:00
'data' => [
'label' => 'test label' ,
'value' => 'test value'
2015-05-07 13:25:26 +00:00
]
2015-04-27 14:05:31 +00:00
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< h2 class = " pi-item pi-item-spacing pi-title " > Test Title </ h2 >
2015-07-31 12:54:10 +00:00
< div class = " pi-item pi-data pi-item-spacing pi-border-color " >
2015-07-29 15:40:21 +00:00
< h3 class = " pi-data-label pi-secondary-font " > test label </ h3 >
< div class = " pi-data-value pi-font " > test value </ div >
2015-05-04 14:30:40 +00:00
</ div >
</ aside > ' ,
2015-05-07 12:36:30 +00:00
'description' => 'Simple infobox with title, empty image and key-value pair'
2015-05-04 14:30:40 +00:00
],
[
'input' => [
[
'type' => 'title' ,
'data' => [
'value' => 'Test Title'
2015-05-07 13:25:26 +00:00
]
2015-05-04 14:30:40 +00:00
],
[
'type' => 'group' ,
'data' => [
'value' => [
[
'type' => 'header' ,
'data' => [
'value' => 'Test Header'
2015-05-07 13:25:26 +00:00
]
2015-05-04 14:30:40 +00:00
],
[
2015-05-07 12:36:30 +00:00
'type' => 'data' ,
2015-05-04 14:30:40 +00:00
'data' => [
'label' => 'test label' ,
'value' => 'test value'
2015-05-07 13:25:26 +00:00
]
2015-05-04 14:30:40 +00:00
],
[
2015-05-07 12:36:30 +00:00
'type' => 'data' ,
2015-05-04 14:30:40 +00:00
'data' => [
'label' => 'test label' ,
'value' => 'test value'
2015-05-07 13:25:26 +00:00
]
2015-05-04 14:30:40 +00:00
]
]
2015-05-07 13:25:26 +00:00
]
2015-05-04 14:30:40 +00:00
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< h2 class = " pi-item pi-item-spacing pi-title " > Test Title </ h2 >
2015-07-31 12:54:10 +00:00
< section class = " pi-item pi-group pi-border-color " >
2015-07-29 15:40:21 +00:00
< h2 class = " pi-item pi-header pi-secondary-font pi-item-spacing pi-secondary-background " > Test Header </ h2 >
2015-07-31 12:54:10 +00:00
< div class = " pi-item pi-data pi-item-spacing pi-border-color " >
2015-07-29 15:40:21 +00:00
< h3 class = " pi-data-label pi-secondary-font " > test label </ h3 >
< div class = " pi-data-value pi-font " > test value </ div >
2015-05-04 14:30:40 +00:00
</ div >
2015-07-31 12:54:10 +00:00
< div class = " pi-item pi-data pi-item-spacing pi-border-color " >
2015-07-29 15:40:21 +00:00
< h3 class = " pi-data-label pi-secondary-font " > test label </ h3 >
< div class = " pi-data-value pi-font " > test value </ div >
2015-05-04 14:30:40 +00:00
</ div >
</ section >
</ aside > ' ,
2015-07-21 11:33:24 +00:00
'description' => 'Infobox with title, group with header and two key-value pairs'
2015-05-04 14:30:40 +00:00
],
2015-06-11 17:28:49 +00:00
[
'input' => [
[
'type' => 'group' ,
'data' => [
'value' => [
[
'type' => 'header' ,
'data' => [
2015-07-29 08:58:39 +00:00
'value' => 'Test header'
]
],
[
'type' => 'data' ,
'data' => [
'label' => 'test label' ,
'value' => 'test value'
2015-06-11 17:28:49 +00:00
]
],
[
'type' => 'data' ,
'data' => [
'label' => 'test label' ,
'value' => 'test value'
]
]
],
'layout' => 'horizontal'
]
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
2015-07-31 12:54:10 +00:00
< section class = " pi-item pi-group pi-border-color " >
2015-07-29 15:40:21 +00:00
< table class = " pi-horizontal-group " >
2015-07-29 08:58:39 +00:00
< caption
2015-07-29 15:40:21 +00:00
class = " pi-header pi-secondary-font pi-secondary-background pi-item-spacing " > Test header </ caption >
2015-07-29 08:58:39 +00:00
< thead >
< tr >
< th
2015-08-04 10:06:14 +00:00
class = " pi-horizontal-group-item pi-data-label pi-secondary-font pi-border-color pi-item-spacing " > test label </ th >
2015-07-29 08:58:39 +00:00
< th
2015-08-04 10:06:14 +00:00
class = " pi-horizontal-group-item pi-data-label pi-secondary-font pi-border-color pi-item-spacing " > test label </ th >
2015-07-29 08:58:39 +00:00
</ tr >
</ thead >
< tbody >
< tr >
2015-07-31 12:54:10 +00:00
< td
2015-08-04 10:06:14 +00:00
class = " pi-horizontal-group-item pi-data-value pi-font pi-border-color pi-item-spacing " > test value </ td >
2015-07-31 12:54:10 +00:00
< td
2015-08-04 10:06:14 +00:00
class = " pi-horizontal-group-item pi-data-value pi-font pi-border-color pi-item-spacing " > test value </ td >
2015-07-29 08:58:39 +00:00
</ tr >
</ tbody >
</ table >
2015-06-11 17:28:49 +00:00
</ section >
</ aside > ' ,
2015-09-07 11:26:07 +00:00
'description' => 'Infobox with horizontal group' ,
2015-07-29 08:58:39 +00:00
'mockParams' => [
'createHorizontalGroupData' => [
'header' => 'Test header' ,
2016-03-29 10:57:07 +00:00
'labels' => [ 'test label' , 'test label' ],
'values' => [ 'test value' , 'test value' ],
2015-09-07 11:26:07 +00:00
'renderLabels' => true
]
]
],
[
'input' => [
[
'type' => 'group' ,
'data' => [
'value' => [
[
'type' => 'data' ,
'data' => [
'label' => '' ,
'value' => 'test value'
]
],
[
'type' => 'data' ,
'data' => [
'label' => '' ,
'value' => 'test value'
]
]
],
'layout' => 'horizontal'
]
]
],
'output' => ' < aside class = " portable-infobox pi-background " >
< section class = " pi-item pi-group pi-border-color " >
2016-03-09 14:51:51 +00:00
< table class = " pi-horizontal-group pi-horizontal-group-no-labels " >
2015-09-07 11:26:07 +00:00
< tbody >
< tr >
< td
class = " pi-horizontal-group-item pi-data-value pi-font pi-border-color pi-item-spacing " > test value </ td >
< td
class = " pi-horizontal-group-item pi-data-value pi-font pi-border-color pi-item-spacing " > test value </ td >
</ tr >
</ tbody >
</ table >
</ section >
</ aside > ' ,
'description' => 'Infobox with horizontal group without header and labels' ,
'mockParams' => [
'createHorizontalGroupData' => [
2016-03-29 10:57:07 +00:00
'labels' => [ '' , '' ],
'values' => [ 'test value' , 'test value' ],
2015-09-07 11:26:07 +00:00
'renderLabels' => false
2015-07-29 08:58:39 +00:00
]
]
2015-06-11 17:28:49 +00:00
],
2015-05-04 14:30:40 +00:00
[
'input' => [
[
2015-07-01 14:19:31 +00:00
'type' => 'navigation' ,
2015-05-04 14:30:40 +00:00
'data' => [
2015-05-07 12:36:30 +00:00
'value' => '<p>Links</p>'
2015-05-07 13:25:26 +00:00
]
2015-05-04 14:30:40 +00:00
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< nav class = " pi-navigation pi-item-spacing pi-secondary-background pi-secondary-font " >
2015-05-04 14:30:40 +00:00
< p > Links </ p >
2015-07-01 14:19:31 +00:00
</ nav >
2015-05-04 14:30:40 +00:00
</ aside > ' ,
2015-07-01 14:19:31 +00:00
'description' => 'Infobox with navigation'
2015-07-10 14:57:57 +00:00
],
2015-05-20 11:56:56 +00:00
[
'input' => [
[
'type' => 'image' ,
'data' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'ref' => 1 ,
2015-07-29 08:58:39 +00:00
'name' => 'test1' ,
2015-07-29 13:22:28 +00:00
'key' => 'test1' ,
'isVideo' => false
2015-05-20 11:56:56 +00:00
]
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< div class = " pi-item pi-hero " >
< img
src = " data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D " data - src = " http://image.jpg " class = " pi-image-thumbnail lazy media article-media " alt = " image alt " data - image - key = " test1 " data - image - name = " test1 " data - ref = " 1 " data - params = \ ' [{ " name " : " test1 " , " full " : " http://image.jpg " }] \ ' />
2015-05-20 11:56:56 +00:00
</ div >
</ aside > ' ,
2016-04-04 13:50:36 +00:00
'description' => 'WikiaMobile: Only image. Image is not small- should render hero.' ,
2015-07-29 08:58:39 +00:00
'mockParams' => [
2016-04-04 13:50:36 +00:00
'isMobile' => true ,
'isMercury' => false ,
2015-07-29 08:58:39 +00:00
'isValidHeroDataItem' => true ,
'extendImageData' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'name' => 'test1' ,
'key' => 'test1' ,
'ref' => 1 ,
'width' => '400' ,
'height' => '200' ,
2015-07-29 13:22:28 +00:00
'thumbnail' => 'http://image.jpg' ,
'media-type' => 'image' ,
'isVideo' => false
2015-07-21 23:13:28 +00:00
]
]
],
2015-07-10 14:57:57 +00:00
[
'input' => [
[
'type' => 'title' ,
'data' => [
2015-07-21 23:13:28 +00:00
'value' => 'Test <img /><a href="example.com">Title</a>'
2015-07-10 14:57:57 +00:00
]
],
[
'type' => 'image' ,
2015-07-21 23:13:28 +00:00
'data' => [
'url' => 'http://image.jpg' ,
2015-07-29 08:58:39 +00:00
'name' => 'test1' ,
'key' => 'test1' ,
2015-07-29 13:22:28 +00:00
'ref' => 44 ,
'isVideo' => false
2015-07-21 23:13:28 +00:00
]
2015-07-10 14:57:57 +00:00
]
],
2015-07-29 15:40:21 +00:00
'output' => ' < aside class = " portable-infobox pi-background " >
< div class = " pi-item pi-hero " >
< hgroup class = " pi-hero-title-wrapper pi-item-spacing " >
2016-01-09 15:01:13 +00:00
< h2 class = " pi-hero-title " > Test < a href = " example.com " > Title </ a ></ h2 >
2015-07-29 15:40:21 +00:00
</ hgroup >
< img
src = " data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D " data - src = " thumbnail.jpg " class = " pi-image-thumbnail lazy media article-media " alt = " " data - image - key = " test1 " data - image - name = " test1 " data - ref = " 44 " data - params = \ ' [{ " name " : " test1 " , " full " : " http://image.jpg " }] \ ' />
</ div >
</ aside > ' ,
2016-04-04 13:50:36 +00:00
'description' => 'WikiaMobile: Infobox with full hero module with title with HTML tags' ,
2015-07-29 08:58:39 +00:00
'mockParams' => [
'isValidHeroDataItem' => true ,
2016-04-04 13:50:36 +00:00
'isMobile' => true ,
'isMercury' => false ,
2015-07-29 08:58:39 +00:00
'extendImageData' => [
'url' => 'http://image.jpg' ,
'name' => 'test1' ,
'key' => 'test1' ,
'ref' => 44 ,
'width' => '400' ,
'height' => '200' ,
2015-07-29 13:22:28 +00:00
'thumbnail' => 'thumbnail.jpg' ,
'isVideo' => false ,
'media-type' => 'image'
2015-07-29 08:58:39 +00:00
]
]
2016-04-04 13:50:36 +00:00
],
[
'input' => [
[
'type' => 'image' ,
'data' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'ref' => 1 ,
'name' => 'test1' ,
'key' => 'test1' ,
'isVideo' => false
]
]
],
'output' => ' < aside class = " portable-infobox pi-background " >
< div class = " pi-item pi-hero " >
2016-04-07 13:14:26 +00:00
< figure data - component = " portable-infobox-hero-image " data - attrs = " { "itemContext":"portable-infobox","ref":1} " >
2016-04-04 13:50:36 +00:00
< a href = " http://image.jpg " >
2016-04-06 13:40:25 +00:00
< img class = " article-media-placeholder " src = " data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D \ 'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg \ ' viewBox%3D \ '0 0 400 200 \ '%2F%3E " alt = " " width = " 400 " height = " 200 " />
2016-04-04 13:50:36 +00:00
< noscript >
< img src = " http://image.jpg " alt = " image alt " width = " 400 " height = " 200 " />
</ noscript >
</ a >
</ figure >
</ div >
</ aside > ' ,
2016-05-18 12:44:36 +00:00
'description' => 'Mercury: Only image. Image is not small- should render hero.' ,
2016-04-04 13:50:36 +00:00
'mockParams' => [
'isMobile' => true ,
'isMercury' => true ,
'isMercuryExperimentalMarkupEnabled' => true ,
'isValidHeroDataItem' => true ,
'extendImageData' => [
'alt' => 'image alt' ,
'url' => 'http://image.jpg' ,
'name' => 'test1' ,
'key' => 'test1' ,
'ref' => 1 ,
'width' => '400' ,
'height' => '200' ,
'thumbnail' => 'http://image.jpg' ,
'media-type' => 'image' ,
'isVideo' => false ,
2016-04-05 15:42:21 +00:00
'mercuryComponentAttrs' => json_encode ( [
2016-04-04 13:50:36 +00:00
'itemContext' => 'portable-infobox' ,
'ref' => 1
] )
]
]
],
[
'input' => [
[
'type' => 'title' ,
'data' => [
'value' => 'Test <img /><a href="example.com">Title</a>'
]
],
[
'type' => 'image' ,
'data' => [
'url' => 'http://image.jpg' ,
'name' => 'test1' ,
'key' => 'test1' ,
'ref' => 44 ,
'isVideo' => false
]
]
],
'output' => ' < aside class = " portable-infobox pi-background " >
< div class = " pi-item pi-hero " >
< hgroup class = " pi-hero-title-wrapper pi-item-spacing " >
< h2 class = " pi-hero-title " > Test < a href = " example.com " > Title </ a ></ h2 >
</ hgroup >
2016-04-07 13:14:26 +00:00
< figure data - component = " portable-infobox-hero-image " data - attrs = " { "itemContext":"portable-infobox","ref":44} " >
2016-04-04 13:50:36 +00:00
< a href = " http://image.jpg " >
2016-04-06 13:40:25 +00:00
< img class = " article-media-placeholder " src = " data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D \ 'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg \ ' viewBox%3D \ '0 0 400 200 \ '%2F%3E " alt = " " width = " 400 " height = " 200 " />
2016-04-04 13:50:36 +00:00
< noscript >
< img src = " http://image.jpg " alt = " " width = " 400 " height = " 200 " />
</ noscript >
</ a >
</ figure >
</ div >
</ aside > ' ,
2016-05-18 12:44:36 +00:00
'description' => 'Mercury: Infobox with full hero module with title with HTML tags' ,
2016-04-04 13:50:36 +00:00
'mockParams' => [
'isValidHeroDataItem' => true ,
'isMobile' => true ,
'isMercury' => true ,
'isMercuryExperimentalMarkupEnabled' => true ,
'extendImageData' => [
'url' => 'http://image.jpg' ,
'name' => 'test1' ,
'key' => 'test1' ,
'ref' => 44 ,
'width' => '400' ,
'height' => '200' ,
'thumbnail' => 'thumbnail.jpg' ,
'isVideo' => false ,
'media-type' => 'image' ,
2016-04-05 15:42:21 +00:00
'mercuryComponentAttrs' => json_encode ( [
2016-04-04 13:50:36 +00:00
'itemContext' => 'portable-infobox' ,
'ref' => 44
] )
]
]
2015-04-27 14:05:31 +00:00
]
];
}
}