PhpOffice\PhpPresentation\Tests\Writer\ODPresentation\ContentTest::testStyleAlignment PHP Method

testStyleAlignment() public method

public testStyleAlignment ( )
    public function testStyleAlignment()
    {
        $phpPresentation = new PhpPresentation();
        $oSlide = $phpPresentation->getActiveSlide();
        $oRichText1 = $oSlide->createRichTextShape();
        $oRichText1->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
        $oRichText1->createTextRun('Run1');
        $p1HashCode = $oRichText1->getActiveParagraph()->getHashCode();
        $oRichText2 = $oSlide->createRichTextShape();
        $oRichText2->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_DISTRIBUTED);
        $oRichText2->createTextRun('Run2');
        $p2HashCode = $oRichText2->getActiveParagraph()->getHashCode();
        $oRichText3 = $oSlide->createRichTextShape();
        $oRichText3->getActiveParagraph()->getAlignment()->setHorizontal('AAAAA');
        $oRichText3->createTextRun('Run3');
        $p3HashCode = $oRichText3->getActiveParagraph()->getHashCode();
        $oRichText4 = $oSlide->createRichTextShape();
        $oRichText4->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_JUSTIFY);
        $oRichText4->createTextRun('Run4');
        $p4HashCode = $oRichText4->getActiveParagraph()->getHashCode();
        $oRichText5 = $oSlide->createRichTextShape();
        $oRichText5->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
        $oRichText5->createTextRun('Run5');
        $p5HashCode = $oRichText5->getActiveParagraph()->getHashCode();
        $oRichText6 = $oSlide->createRichTextShape();
        $oRichText6->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
        $oRichText6->createTextRun('Run6');
        $p6HashCode = $oRichText6->getActiveParagraph()->getHashCode();
        $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p1HashCode . '\']/style:paragraph-properties';
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertEquals('center', $pres->getElementAttribute($element, 'fo:text-align', 'content.xml'));
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p2HashCode . '\']/style:paragraph-properties';
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertEquals('justify', $pres->getElementAttribute($element, 'fo:text-align', 'content.xml'));
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p3HashCode . '\']/style:paragraph-properties';
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertEquals('left', $pres->getElementAttribute($element, 'fo:text-align', 'content.xml'));
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p4HashCode . '\']/style:paragraph-properties';
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertEquals('justify', $pres->getElementAttribute($element, 'fo:text-align', 'content.xml'));
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p5HashCode . '\']/style:paragraph-properties';
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertEquals('left', $pres->getElementAttribute($element, 'fo:text-align', 'content.xml'));
        $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p6HashCode . '\']/style:paragraph-properties';
        $this->assertTrue($pres->elementExists($element, 'content.xml'));
        $this->assertEquals('right', $pres->getElementAttribute($element, 'fo:text-align', 'content.xml'));
    }