|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of PHPWord - A pure PHP library for reading and writing |
| 5 | + * word processing documents. |
| 6 | + * |
| 7 | + * PHPWord is free software distributed under the terms of the GNU Lesser |
| 8 | + * General Public License version 3 as published by the Free Software Foundation. |
| 9 | + * |
| 10 | + * For the full copyright and license information, please read the LICENSE |
| 11 | + * file that was distributed with this source code. For the full list of |
| 12 | + * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
| 13 | + * |
| 14 | + * @see https://github.com/PHPOffice/PHPWord |
| 15 | + * |
| 16 | + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 17 | + */ |
| 18 | + |
| 19 | +namespace PhpOffice\PhpWordTests\Writer\RTF\Style; |
| 20 | + |
| 21 | +use PhpOffice\PhpWord\Settings; |
| 22 | +use PhpOffice\PhpWord\SimpleType\Border as BorderType; |
| 23 | +use PhpOffice\PhpWord\Style\Border as BorderStyle; |
| 24 | +use PhpOffice\PhpWord\Writer\RTF; |
| 25 | +use PhpOffice\PhpWord\Writer\RTF\Style\Border as BorderWriter; |
| 26 | +use PHPUnit\Framework\TestCase; |
| 27 | + |
| 28 | +class BorderTest extends TestCase |
| 29 | +{ |
| 30 | + protected function tearDown(): void |
| 31 | + { |
| 32 | + Settings::setDefaultRtl(null); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @param BorderWriter $field |
| 37 | + */ |
| 38 | + public function removeCr($field): string |
| 39 | + { |
| 40 | + return str_replace("\r\n", "\n", $field->write()); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Test Border styles in paragraph. |
| 45 | + * See page 89-90 of RTF Specification 1.9.1 for Paragraph Borders. |
| 46 | + */ |
| 47 | + public function testBorderStyle(): void |
| 48 | + { |
| 49 | + $parentWriter = new RTF(); |
| 50 | + $style = new BorderStyle(); |
| 51 | + $writer = new BorderWriter($style); |
| 52 | + $writer->setParentWriter($parentWriter); |
| 53 | + |
| 54 | + $border->setBorderSize(40); |
| 55 | + $border->setBorderColor('#FF0000'); |
| 56 | + $border->setBorderStyle(BorderType::DASHED); |
| 57 | + $border->setBorderSpace(20); |
| 58 | + |
| 59 | + $expected .= '\brdrt\brdrdash\brdrw40\brdrcf0\brsp20 '; |
| 60 | + $expected .= '\brdrl\brdrdash\brdrw40\brdrcf0\brsp20 '; |
| 61 | + $expected .= '\brdrr\brdrdash\brdrw40\brdrcf0\brsp20 '; |
| 62 | + $expected .= '\brdrb\brdrdash\brdrw40\brdrcf0\brsp20 '; |
| 63 | + self::assertEquals($expect, $this->removeCr($writer)); |
| 64 | + } |
| 65 | +} |
0 commit comments