setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php'; parent::setUp(); } /** * @covers NodeSet::getRenderData * @dataProvider renderDataProvider * * @param $markup * @param $params * @param $expected */ public function testRenderData( $markup, $params, $expected ) { $node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, $params ); $this->assertEquals( $expected, $node->getRenderData() ); } public function renderDataProvider() { return [ [ '
h
', [ '1' => 'one', '2' => 'two' ], [ 'type' => 'set', 'data' => [ 'value' => [ [ 'type' => 'header', 'data' => [ 'value' => 'h' ] ], [ 'type' => 'data', 'data' => [ 'value' => 'one', 'label' => '' ] ], [ 'type' => 'data', 'data' => [ 'value' => 'two', 'label' => '' ] ], ] ] ] ], [ '
h
', [ '1' => 'one' ], [ 'type' => 'set', 'data' => [ 'value' => [ [ 'type' => 'header', 'data' => [ 'value' => 'h' ] ], [ 'type' => 'data', 'data' => [ 'value' => 'one', 'label' => '' ] ], [ 'type' => 'data', 'data' => [ 'value' => null, 'label' => '' ] ] ] ] ] ], [ '
h
', [ ], [ 'type' => 'set', 'data' => [ 'value' => [ [ 'type' => 'header', 'data' => [ 'value' => 'h' ] ], [ 'type' => 'data', 'data' => [ 'value' => null, 'label' => '' ] ], [ 'type' => 'data', 'data' => [ 'value' => null, 'label' => '' ] ], ] ] ] ] ]; } /** * @dataProvider testIsEmptyDataProvider */ public function testIsEmpty( $val1, $val2, $expectedOutput ) { $string = '
Comparison1
'; $xml = simplexml_load_string( $string ); $nodeSet = new Wikia\PortableInfobox\Parser\Nodes\NodeSet( $xml, [ 'val1' => $val1, 'val2' => $val2 ] ); $data = $nodeSet->getData(); $this->assertTrue( $nodeSet->isEmpty( $data ) == $expectedOutput ); } public function testIsEmptyDataProvider() { return [ [ 'val1' => 'obi-wan', 'val2' => 'luke', 'expectedOutput' => false ], [ 'val1' => null, 'val2' => 1, 'expectedOutput' => false ], [ 'val1' => 'yoda', 'val2' => null, 'expectedOutput' => false ], [ 'val1' => '0', 'val2' => '0', 'expectedOutput' => false ], [ 'val1' => null, 'val2' => [ ], 'expectedOutput' => true ] ]; } }