|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This file is part of PHPWord - A pure PHP library for reading and writing |
| 4 | + * word processing documents. |
| 5 | + * |
| 6 | + * PHPWord is free software distributed under the terms of the GNU Lesser |
| 7 | + * General Public License version 3 as published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * For the full copyright and license information, please read the LICENSE |
| 10 | + * file that was distributed with this source code. For the full list of |
| 11 | + * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
| 12 | + * |
| 13 | + * @see https://github.com/PHPOffice/PHPWord |
| 14 | + * |
| 15 | + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 16 | + */ |
| 17 | + |
| 18 | +namespace PhpOffice\PhpWordTests\Writer\ODText\Element; |
| 19 | + |
| 20 | +use PhpOffice\PhpWord\PhpWord; |
| 21 | +use PhpOffice\PhpWordTests\TestHelperDOCX; |
| 22 | +use PHPUnit\Framework\TestCase; |
| 23 | + |
| 24 | +/** |
| 25 | + * Test class for PhpOffice\PhpWord\Writer\ODText\Element subnamespace. |
| 26 | + */ |
| 27 | +class FieldTest extends TestCase |
| 28 | +{ |
| 29 | + /** |
| 30 | + * Executed before each method of the class. |
| 31 | + */ |
| 32 | + protected function tearDown(): void |
| 33 | + { |
| 34 | + TestHelperDOCX::clear(); |
| 35 | + } |
| 36 | + |
| 37 | + public function testFieldFilename(): void |
| 38 | + { |
| 39 | + $phpWord = new PhpWord(); |
| 40 | + |
| 41 | + $section = $phpWord->addSection(); |
| 42 | + $section->addField('FILENAME'); |
| 43 | + |
| 44 | + $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); |
| 45 | + |
| 46 | + self::assertTrue($doc->elementExists('/office:document-content/office:body/office:text/text:section/text:span/text:file-name')); |
| 47 | + self::assertEquals('false', $doc->getElementAttribute('/office:document-content/office:body/office:text/text:section/text:span/text:file-name', 'text:fixed')); |
| 48 | + self::assertEquals('name', $doc->getElementAttribute('/office:document-content/office:body/office:text/text:section/text:span/text:file-name', 'text:display')); |
| 49 | + } |
| 50 | + |
| 51 | + public function testFieldFilenameOptionPath(): void |
| 52 | + { |
| 53 | + $phpWord = new PhpWord(); |
| 54 | + |
| 55 | + $section = $phpWord->addSection(); |
| 56 | + $section->addField('FILENAME', [], ['Path']); |
| 57 | + |
| 58 | + $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); |
| 59 | + |
| 60 | + self::assertTrue($doc->elementExists('/office:document-content/office:body/office:text/text:section/text:span/text:file-name')); |
| 61 | + self::assertEquals('false', $doc->getElementAttribute('/office:document-content/office:body/office:text/text:section/text:span/text:file-name', 'text:fixed')); |
| 62 | + self::assertEquals('full', $doc->getElementAttribute('/office:document-content/office:body/office:text/text:section/text:span/text:file-name', 'text:display')); |
| 63 | + } |
| 64 | +} |
0 commit comments