/** * @test * @dataProvider autoMarginConvertProvider */ public function autoMarginConvert($nodeWidth, $parentWidth, $expectedMarginLeft, $expectedMarginRight) { $node = new Container(array('width' => $nodeWidth)); $node->setWidth($nodeWidth); $node->setMargin(0, 'auto'); $mock = $this->getMock('\\PHPPdf\\Core\\Node\\Page', array('getWidth', 'setWidth')); $mock->expects($this->atLeastOnce())->method('getWidth')->will($this->returnValue($parentWidth)); if ($nodeWidth > $parentWidth) { $mock->expects($this->once())->method('setWidth')->with($nodeWidth); } $mock->add($node); $this->formatter->format($node, $this->document); $this->assertEquals($expectedMarginLeft, $node->getMarginLeft()); $this->assertEquals($expectedMarginRight, $node->getMarginRight()); }