getSettings()->getDocumentProtection()->setEditing('forms'); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:documentProtection'; $this->assertTrue($doc->elementExists($path, $file)); } /** * Test compatibility */ public function testCompatibility() { $phpWord = new PhpWord(); $phpWord->getCompatibility()->setOoxmlVersion(15); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:compat/w:compatSetting'; $this->assertTrue($doc->elementExists($path, $file)); $this->assertEquals($phpWord->getCompatibility()->getOoxmlVersion(), 15); } /** * Test language */ public function testDefaultLanguage() { $phpWord = new PhpWord(); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:themeFontLang'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertEquals('en-US', $element->getAttribute('w:val')); } /** * Test language */ public function testLanguage() { $phpWord = new PhpWord(); $phpWord->getSettings()->setThemeFontLang(new Language(Language::DE_DE, Language::KO_KR, Language::HE_IL)); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:themeFontLang'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertEquals(Language::DE_DE, $element->getAttribute('w:val')); $this->assertEquals(Language::KO_KR, $element->getAttribute('w:eastAsia')); $this->assertEquals(Language::HE_IL, $element->getAttribute('w:bidi')); } /** * Test spelling */ public function testSpelling() { $phpWord = new PhpWord(); $phpWord->getSettings()->setHideSpellingErrors(true); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:hideSpellingErrors'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertNotEquals('false', $element->getAttribute('w:val')); } /** * Test even and odd headers */ public function testEvenAndOddHeaders() { $phpWord = new PhpWord(); $phpWord->getSettings()->setEvenAndOddHeaders(true); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:evenAndOddHeaders'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertNotEquals('false', $element->getAttribute('w:val')); } /** * Test zoom percentage */ public function testZoomPercentage() { $phpWord = new PhpWord(); $phpWord->getSettings()->setZoom(75); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:zoom'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertEquals('75', $element->getAttribute('w:percent')); } /** * Test zoom value */ public function testZoomValue() { $phpWord = new PhpWord(); $phpWord->getSettings()->setZoom(Zoom::FULL_PAGE); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:zoom'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertEquals('fullPage', $element->getAttribute('w:val')); } /** * Test Revision View */ public function testRevisionView() { $trackChangesView = new TrackChangesView(); $trackChangesView->setFormatting(false); $trackChangesView->setComments(true); $phpWord = new PhpWord(); $phpWord->getSettings()->setRevisionView($trackChangesView); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:revisionView'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertEquals('false', $element->getAttribute('w:formatting')); $this->assertEquals('true', $element->getAttribute('w:comments')); } /** * Test track Revisions */ public function testTrackRevisions() { $phpWord = new PhpWord(); $phpWord->getSettings()->setTrackRevisions(true); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:trackRevisions'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertNotEquals('false', $element->getAttribute('w:val')); } /** * Test doNotTrackMoves */ public function testDoNotTrackMoves() { $phpWord = new PhpWord(); $phpWord->getSettings()->setDoNotTrackMoves(true); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:doNotTrackMoves'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertNotEquals('false', $element->getAttribute('w:val')); } /** * Test DoNotTrackFormatting */ public function testDoNotTrackFormatting() { $phpWord = new PhpWord(); $phpWord->getSettings()->setDoNotTrackFormatting(true); $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/settings.xml'; $path = '/w:settings/w:doNotTrackFormatting'; $this->assertTrue($doc->elementExists($path, $file)); $element = $doc->getElement($path, $file); $this->assertNotEquals('false', $element->getAttribute('w:val')); } }