setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php';
parent::setUp();
}
/**
* @covers \Wikia\PortableInfobox\Parser\Nodes\NodeGroup::getData
* @dataProvider groupNodeCollapseTestProvider
*
* @param $markup
* @param $expected
*/
public function testNodeGroupCollapse( $markup, $expected ) {
$node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup );
$this->assertEquals( $expected, $node->getData()[ 'collapse' ] );
}
public function groupNodeCollapseTestProvider() {
return [
[ '', null ],
[ '', null ],
[ '', 'open' ],
[ '', 'closed' ]
];
}
/**
* @covers \Wikia\PortableInfobox\Parser\Nodes\NodeGroup::getData
* @covers \Wikia\PortableInfobox\Parser\Nodes\NodeGroup::getRenderData
* @dataProvider groupNodeRowItemsTestProvider
*
* @param $markup
* @param $expected
*/
public function testNodeGroupRowItems( $markup, $expected ) {
$node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup );
$this->assertEquals( $expected, $node->getData()[ 'row-items' ] );
$this->assertEquals( $expected, $node->getRenderData()[ 'data' ][ 'row-items' ] );
}
public function groupNodeRowItemsTestProvider() {
return [
[ '', null ],
[ '', null ],
[ '', null ],
[ '', '5' ],
[ '', '50' ],
];
}
/**
* @covers \Wikia\PortableInfobox\Parser\Nodes\NodeGroup::getData
* @dataProvider groupNodeTestProvider
*
* @param $markup
* @param $params
* @param $expected
*/
public function testNodeGroup( $markup, $params, $expected ) {
$node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, $params );
$this->assertEquals( $expected, $node->getData() );
}
public function groupNodeTestProvider() {
return [
[ 'def1
def2',
[ 'elem1' => 1, 'elem2' => 2 ],
[ 'value' =>
[
[ 'type' => 'data', 'isEmpty' => false, 'data' => [ 'label' => 'l1', 'value' => 1, 'span' => 1, 'layout' => null ],
'source' => [ 'elem1' ] ],
[ 'type' => 'data', 'isEmpty' => false, 'data' => [ 'label' => 'l2', 'value' => 2, 'span' => 1, 'layout' => null ],
'source' => [ 'elem2' ] ],
[ 'type' => 'data', 'isEmpty' => true, 'data' => [ 'label' => 'l2', 'value' => null, 'span' => 1, 'layout' => null ],
'source' => [ 'elem3' ] ]
],
'layout' => 'default',
'collapse' => null,
'row-items' => null
] ],
[ 'def1
def2',
[ 'elem1' => 1, 'elem2' => 2 ],
[ 'value' =>
[
[ 'type' => 'data', 'isEmpty' => false, 'data' => [ 'label' => 'l1', 'value' => 1, 'span' => 1, 'layout' => null ],
'source' => [ 'elem1' ] ],
[ 'type' => 'data', 'isEmpty' => false, 'data' => [ 'label' => 'l2', 'value' => 2, 'span' => 1, 'layout' => null ],
'source' => [ 'elem2' ] ],
[ 'type' => 'data', 'isEmpty' => true, 'data' => [ 'label' => 'l2', 'value' => null, 'span' => 1, 'layout' => null ],
'source' => [ 'elem3' ] ],
],
'layout' => 'horizontal',
'collapse' => null,
'row-items' => null
] ],
[ 'def1
def2',
[ 'elem1' => 1, 'elem2' => 2 ],
[ 'value' =>
[
[ 'type' => 'data', 'isEmpty' => false, 'data' => [ 'label' => 'l1', 'value' => 1, 'span' => 1, 'layout' => null ],
'source' => [ 'elem1' ] ],
[ 'type' => 'data', 'isEmpty' => false, 'data' => [ 'label' => 'l2', 'value' => 2, 'span' => 1, 'layout' => null ],
'source' => [ 'elem2' ] ],
[ 'type' => 'data', 'isEmpty' => true, 'data' => [ 'label' => 'l2', 'value' => null, 'span' => 1, 'layout' => null ],
'source' => [ 'elem3' ] ],
],
'layout' => 'default',
'collapse' => null,
'row-items' => null
] ],
[ '',
[ '1' => 'one', '2' => 'two' ],
[ 'value' => [
[ 'type' => 'header', 'data' => [ 'value' => 'h' ], 'isEmpty' => false, 'source' => [ ] ],
[ 'type' => 'data', 'data' => [ 'value' => 'one', 'label' => '', 'span' => 1, 'layout' => null ], 'isEmpty' => false,
'source' => [ '1' ] ],
[ 'type' => 'data', 'data' => [ 'value' => 'two', 'label' => '', 'span' => 1, 'layout' => null ], 'isEmpty' => false,
'source' => [ '2' ] ],
],
'layout' => 'default',
'collapse' => null,
'row-items' => null
] ],
[ '',
[ '1' => 'one' ],
[ 'value' => [
[ 'type' => 'header', 'data' => [ 'value' => 'h' ], 'isEmpty' => false, 'source' => [ ] ],
[ 'type' => 'data', 'data' => [ 'value' => 'one', 'label' => '', 'span' => 1, 'layout' => null ], 'isEmpty' => false,
'source' => [ '1' ] ],
[ 'type' => 'data', 'data' => [ 'value' => null, 'label' => '', 'span' => 1, 'layout' => null ], 'isEmpty' => true,
'source' => [ '2' ] ]
],
'layout' => 'default',
'collapse' => null,
'row-items' => null
] ],
[ '', [ ],
[ 'value' => [
[ 'type' => 'header', 'data' => [ 'value' => 'h' ], 'isEmpty' => false, 'source' => [ ] ],
[ 'type' => 'data', 'data' => [ 'value' => null, 'label' => '', 'span' => 1, 'layout' => null ], 'isEmpty' => true,
'source' => [ '1' ] ],
[ 'type' => 'data', 'data' => [ 'value' => null, 'label' => '', 'span' => 1, 'layout' => null ], 'isEmpty' => true,
'source' => [ '2' ] ],
],
'layout' => 'default',
'collapse' => null,
'row-items' => null
] ]
];
}
}