setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php'; parent::setUp(); } /** * @covers NodeImage::getData * @dataProvider dataProvider * * @param $markup * @param $params * @param $expected */ public function testData( $markup, $params, $expected ) { $node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, $params ); $this->assertEquals( $expected, $node->getData() ); } public function dataProvider() { return [ [ '', [ ], [ 'url' => '', 'name' => '', 'key' => '', 'alt' => null, 'caption' => null, 'ref' => null ] ], [ '', [ 'img' => 'test.jpg' ], [ 'url' => '', 'name' => 'Test.jpg', 'key' => 'Test.jpg', 'alt' => null, 'caption' => null, 'ref' => 0 ] ], [ 'test alt', [ 'img' => 'test.jpg' ], [ 'url' => '', 'name' => 'Test.jpg', 'key' => 'Test.jpg', 'alt' => 'test alt', 'caption' => null, 'ref' => 1 ] ], [ 'test alt', [ 'img' => 'test.jpg', 'alt source' => 2 ], [ 'url' => '', 'name' => 'Test.jpg', 'key' => 'Test.jpg', 'alt' => 2, 'caption' => null, 'ref' => 2 ] ], [ 'test alt', [ 'img' => 'test.jpg' ], [ 'url' => '', 'name' => 'Test.jpg', 'key' => 'Test.jpg', 'alt' => 'test alt', 'caption' => 'test.jpg', 'ref' => 3 ] ], ]; } /** * @covers NodeImage::isEmpty * @dataProvider isEmptyProvider * * @param $markup * @param $params * @param $expected */ public function testIsEmpty( $markup, $params, $expected ) { $node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, $params ); $this->assertEquals( $expected, $node->isEmpty() ); } public function isEmptyProvider() { return [ [ '', [ ], true ], ]; } /** * @covers NodeImage::getSource * @dataProvider sourceProvider * * @param $markup * @param $expected */ public function testSource( $markup, $expected ) { $node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, [ ] ); $this->assertEquals( $expected, $node->getSource() ); } public function sourceProvider() { return [ [ '', [ 'img' ] ], [ '{{{img}}}', [ 'img' ] ], [ '', [ 'img', 'alt', 'cap' ] ], [ '{{{def}}}', [ 'img', 'alt', 'def', 'cap' ] ], [ '', [ ] ], ]; } }