Skip to content

Commit 4f22889

Browse files
committed
Another Coverage Tweak
1 parent 3961854 commit 4f22889

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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\WriteReadback;
20+
21+
use PhpOffice\PhpWord\Element\TextRun;
22+
use PhpOffice\PhpWord\IOFactory;
23+
use PhpOffice\PhpWord\PhpWord;
24+
use PhpOffice\PhpWord\Writer\RTF;
25+
26+
class RtfBackslashTest extends \PHPUnit\Framework\TestCase
27+
{
28+
public function testBackslash(): void
29+
{
30+
$phpWordWriter = new PhpWord();
31+
$textWithBackslash = 'Hello\\World!';
32+
$sectionWriter = $phpWordWriter->addSection();
33+
$sectionWriter->addText($textWithBackslash);
34+
35+
$writer = new RTF($phpWordWriter);
36+
$file = __DIR__ . '/../_files/temp.rtf';
37+
$writer->save($file);
38+
self::assertFileExists($file);
39+
$phpWordReader = IOFactory::load($file, 'RTF');
40+
unlink($file);
41+
42+
$sections = $phpWordReader->getSections();
43+
self::assertCount(1, $sections);
44+
$elements = $sections[0]->getElements();
45+
$element = $elements[0];
46+
self::assertInstanceOf(TextRun::class, $element);
47+
self::assertSame($textWithBackslash, $element->getText());
48+
}
49+
}

0 commit comments

Comments
 (0)