/** * @test * @dataProvider dataProvider */ public function givenRatioDoesntMatchOriginalRatio_fixDimensionToFitOriginalRatio($originalWidth, $originalHeight, $currentWidth, $currentHeight, $expectedWidth, $expectedHeight) { //given $image = NodeBuilder::create()->nodeClass('PHPPdf\\Test\\Helper\\Image')->attr('original-width', $originalWidth)->attr('original-height', $originalHeight)->attr('width', $currentWidth)->attr('height', $currentHeight)->getNode(); //when $this->formatter->format($image, $this->document); //then NodeAssert::create($image)->width($expectedWidth)->height($expectedHeight); }
/** * @test */ public function givenNodeAndParentWithDimensions_nodeWidthCantExceedParentWidth() { $node = NodeBuilder::create()->attr('width', 90)->attr('height', 90)->attr('padding', 10)->parent()->attr('width', 100)->attr('height', 100)->attr('padding', 2)->end()->getNode(); $this->formatter->format($node, $this->document); NodeAssert::create($node)->height(90 + 2 * 10)->widthAsTheSameAsParentsWithoutPaddings(); }
/** * @test */ public function givenMaxDimension_nodeCantExceedMaxDimension() { $node = NodeBuilder::create()->attr('width', 200)->attr('height', 200)->attr('max-width', 150)->attr('max-height', 120)->getNode(); $this->formatter->format($node, $this->document); NodeAssert::create($node)->width(150)->height(120); }