|
| 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 | + * @link https://github.com/PHPOffice/PHPWord |
| 14 | + * @copyright 2010-2014 PHPWord contributors |
| 15 | + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 16 | + */ |
| 17 | + |
| 18 | +namespace PhpOffice\PhpWord\Tests\Shared; |
| 19 | + |
| 20 | +use PhpOffice\PhpWord\Element\Section; |
| 21 | +use PhpOffice\PhpWord\Shared\Html; |
| 22 | + |
| 23 | +/** |
| 24 | + * Test class for PhpOffice\PhpWord\Shared\Html |
| 25 | + */ |
| 26 | +class HtmlTest extends \PHPUnit_Framework_TestCase |
| 27 | +{ |
| 28 | + /** |
| 29 | + * Test unit conversion functions with various numbers |
| 30 | + */ |
| 31 | + public function testAddHtml() |
| 32 | + { |
| 33 | + $content = ''; |
| 34 | + |
| 35 | + // Default |
| 36 | + $section = new Section(1); |
| 37 | + $this->assertEquals(0, $section->countElements()); |
| 38 | + |
| 39 | + // Heading |
| 40 | + $styles = array('strong', 'em', 'sup', 'sub'); |
| 41 | + for ($level = 1; $level <= 6; $level++) { |
| 42 | + $content .= "<h{$level}>Heading {$level}</h{$level}>"; |
| 43 | + } |
| 44 | + |
| 45 | + // Styles |
| 46 | + $content .= '<p style="text-decoration: underline; text-decoration: line-through; ' . |
| 47 | + 'text-align: center; color: #999; background-color: #000;">'; |
| 48 | + foreach ($styles as $style) { |
| 49 | + $content .= "<{$style}>{$style}</{$style}>"; |
| 50 | + } |
| 51 | + $content .= '</p>'; |
| 52 | + |
| 53 | + // Add HTML |
| 54 | + Html::addHtml($section, $content); |
| 55 | + $this->assertEquals(7, $section->countElements()); |
| 56 | + |
| 57 | + // Other parts |
| 58 | + $section = new Section(1); |
| 59 | + $content = ''; |
| 60 | + $content .= '<table><tr><th>Header</th><td>Content</td></tr></table>'; |
| 61 | + $content .= '<ul><li>Bullet</li></ul>'; |
| 62 | + $content .= '<ol><li>Bullet</li></ol>'; |
| 63 | + Html::addHtml($section, $content, null, array('listdepth' => 2)); |
| 64 | + } |
| 65 | +} |
0 commit comments