PhpOffice\PhpPresentation\Tests\Writer\ODPresentation\ContentTest::testRichTextBorder PHP Méthode

testRichTextBorder() public méthode

public testRichTextBorder ( )
    public function testRichTextBorder()
    {
        $phpPresentation = new PhpPresentation();
        $oSlide = $phpPresentation->getActiveSlide();
        $oRichText1 = $oSlide->createRichTextShape();
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1\']/style:graphic-properties';
        $oRichText1->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_SOLID)->setLineStyle(Border::LINE_NONE);
        $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertFalse($pres->attributeElementExists($element, 'svg:stroke-color', 'content.xml'));
        $this->assertFalse($pres->attributeElementExists($element, 'svg:stroke-width', 'content.xml'));
        $this->assertTrue($pres->attributeElementExists($element, 'draw:stroke', 'content.xml'));
        $this->assertEquals('none', $pres->getElementAttribute($element, 'draw:stroke', 'content.xml'));
        $oRichText1->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_SOLID)->setLineStyle(Border::LINE_SINGLE);
        $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertTrue($pres->attributeElementExists($element, 'svg:stroke-color', 'content.xml'));
        $this->assertEquals('#' . $oRichText1->getBorder()->getColor()->getRGB(), $pres->getElementAttribute($element, 'svg:stroke-color', 'content.xml'));
        $this->assertTrue($pres->attributeElementExists($element, 'svg:stroke-width', 'content.xml'));
        $this->assertStringEndsWith('cm', $pres->getElementAttribute($element, 'svg:stroke-width', 'content.xml'));
        $this->assertStringStartsWith((string) number_format(CommonDrawing::pointsToCentimeters($oRichText1->getBorder()->getLineWidth()), 3, '.', ''), $pres->getElementAttribute($element, 'svg:stroke-width', 'content.xml'));
        $this->assertTrue($pres->attributeElementExists($element, 'draw:stroke', 'content.xml'));
        $this->assertEquals('solid', $pres->getElementAttribute($element, 'draw:stroke', 'content.xml'));
        $this->assertFalse($pres->attributeElementExists($element, 'draw:stroke-dash', 'content.xml'));
        $oRichText1->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_DASH);
        $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1\']/style:graphic-properties';
        $this->assertEquals('dash', $pres->getElementAttribute($element, 'draw:stroke', 'content.xml'));
        $this->assertTrue($pres->attributeElementExists($element, 'draw:stroke-dash', 'content.xml'));
        $this->assertStringStartsWith('strokeDash_', $pres->getElementAttribute($element, 'draw:stroke-dash', 'content.xml'));
        $this->assertStringEndsWith($oRichText1->getBorder()->getDashStyle(), $pres->getElementAttribute($element, 'draw:stroke-dash', 'content.xml'));
    }