XW-1429 | add unit tests for moveFirstMarkerToTop method

This commit is contained in:
Igor Rogatty 2016-05-09 14:50:37 +02:00
parent 464bd9ccee
commit bc7f3efb35
2 changed files with 60 additions and 1 deletions

View file

@ -10,12 +10,12 @@ class PortableInfoboxParserTagController extends WikiaController {
const INFOBOX_LAYOUT_PREFIX = 'pi-layout-';
private $markerNumber = 0;
private $markers = [ ];
private $supportedLayouts = [
'default',
'stacked'
];
protected $markers = [ ];
protected static $instance;
/**

View file

@ -241,4 +241,63 @@ class PortableInfoboxParserTagControllerTest extends WikiaBaseTest {
[ 'abc' => 'minus one', '0' => 'zero', '1' => 'one', '2' => 'two', '3' => 'three' ] ],
];
}
/**
* @dataProvider moveFirstMarkerToTopDataProvider
*/
public function testMoveFirstMarkerToTop( $markers, $text, $expected ) {
$this->controller->markers = $markers;
$this->controller->moveFirstMarkerToTop( $text );
$this->assertEquals( $expected, $text );
}
public function moveFirstMarkerToTopDataProvider() {
return [
[
'markers' => [
'infobox-1' => '1',
'infobox-2' => '2',
],
'text' => 'infobox-1 some text infobox-2',
'expected' => 'infobox-1 some text infobox-2',
'message' => 'first infobox already at the top'
],
[
'markers' => [
'infobox-1' => '1',
'infobox-2' => '2',
],
'text' => 'some text infobox-1 infobox-2',
'expected' => 'infobox-1 some text infobox-2',
'message' => 'first infobox below text'
],
[
'markers' => [
'infobox-1' => '1'
],
'text' => 'nospaceinfobox-1',
'expected' => 'infobox-1nospace',
'message' => 'no space between elements'
],
[
'markers' => [
'infobox-1' => '1',
'infobox-2' => '2',
],
'text' => 'some text
some more
infobox-1
more text
infobox-2
and some more',
'expected' => 'infobox-1
some text
some more
more text
infobox-2
and some more',
'message' => 'multiple lines'
],
];
}
}