/** * @test * @dataProvider drawingDataProvider */ public function drawLinePartUsingTextNodeAttributes($fontSize, $lineHeightOfText, $textDecoration, $expectedLineDecorationYCoord, $wordSpacing) { $fontStub = $this->createFontStub(); $startPoint = Point::getInstance(100, 120); $documentStub = $this->createDocumentStub(); $linePartWidthGross = self::WIDTH + ($this->getWordsCount() - 1) * $wordSpacing; $expectedXCoord = $startPoint->getX() + self::X_TRANSLATION; $expectedYCoord = $startPoint->getY() - $fontSize - (self::LINE_HEIGHT - $lineHeightOfText); $expectedWordSpacing = $wordSpacing !== null ? $wordSpacing : 0; $gc = $this->getMock('PHPPdf\\Core\\Engine\\GraphicsContext'); $this->expectDrawText($gc, Point::getInstance($expectedXCoord, $expectedYCoord), $fontStub, $fontSize, $expectedWordSpacing); if ($expectedLineDecorationYCoord === false) { $gc->expects($this->never())->method('drawLine'); } else { $expectedYCoord = $expectedYCoord + $expectedLineDecorationYCoord; $this->expectDrawLine($gc, self::COLOR, Point::getInstance($expectedXCoord, $expectedYCoord), Point::getInstance($expectedXCoord + $linePartWidthGross, $expectedYCoord)); } $text = $this->createTextStub($fontStub, $gc, array('alpha' => self::ALPHA, 'font-size' => $fontSize, 'color' => self::COLOR, 'line-height' => $lineHeightOfText, 'text-decoration' => $textDecoration)); $line = $this->createLineStub($startPoint, self::LINE_HEIGHT); $linePart = new LinePart(self::WORDS, self::WIDTH, self::X_TRANSLATION, $text); $linePart->setWordSpacing($wordSpacing); $linePart->setLine($line); $tasks = new DrawingTaskHeap(); $linePart->collectOrderedDrawingTasks($documentStub, $tasks); foreach ($tasks as $task) { $task->invoke(); } }
public function addPart(LinePart $linePart) { $linePart->setLine($this); $this->parts[] = $linePart; }