/** * @test */ public function convertColor() { $color = 'color'; $result = '#000000'; $node = new Container(); $node->setAttribute('color', $color); $document = $this->getMockBuilder('PHPPdf\\Core\\Document')->setMethods(array('getColorFromPalette'))->disableOriginalConstructor()->getMock(); $document->expects($this->once())->method('getColorFromPalette')->with($color)->will($this->returnValue($result)); $this->formatter->format($node, $document); $this->assertEquals($result, $node->getAttribute('color')); }
/** * @test * @dataProvider resizeDataProvider */ public function resizeCausesBoundaryPointsTranslations($horizontalResizeBy, $verticalResizeBy, $width, $childWidth, $paddingRight, $childMarginRight, $childRelativeWidth = null) { $boundary = $this->createResizableBoundaryMock($width, $horizontalResizeBy, $verticalResizeBy, 2); if ($childRelativeWidth !== null) { $relativeWidth = (int) $childRelativeWidth / 100; $childResizeBy = ($width + $horizontalResizeBy) * $relativeWidth - $childWidth; } else { $childResizeBy = $horizontalResizeBy + ($width - $paddingRight - ($childWidth + $childMarginRight)); $childResizeBy = $childResizeBy < 0 ? $childResizeBy : 0; } $childBoundary = $this->createResizableBoundaryMock($childWidth, $childResizeBy, 0, $childResizeBy != 0 ? 4 : false); $child = new Container(); $child->setAttribute('margin-right', $childMarginRight); $child->setRelativeWidth($childRelativeWidth); $this->node->add($child); $this->node->setAttribute('padding-right', $paddingRight); $this->invokeMethod($this->node, 'setBoundary', array($boundary)); $this->invokeMethod($child, 'setBoundary', array($childBoundary)); $this->node->resize($horizontalResizeBy, $verticalResizeBy); }
public function setWatermark(Container $watermark) { $watermark->setParent($this); $watermark->setAttribute('vertical-align', self::VERTICAL_ALIGN_MIDDLE); $watermark->setHeight($this->getHeight()); $watermark->setWidth($this->getWidth()); $watermark->setBoundary(clone $this->getBoundary()); $this->watermark = $watermark; }
/** * @test * @dataProvider positionProvider */ public function getsClosestAncestorWithPosition($position, $expectedFalse) { $grandparent = new Container(); $parent = new Container(); $grandparent->add($parent); $parent->add($this->node); $grandparent->setAttribute('position', $position); $actualAncestor = $this->node->getClosestAncestorWithPosition(); if ($expectedFalse) { $this->assertFalse($actualAncestor); } else { $this->assertEquals($grandparent, $actualAncestor); } }