Esempio n. 1
11
 /**
  * Test unit conversion functions with various numbers
  */
 public function testAddHtml()
 {
     $content = '';
     // Default
     $section = new Section(1);
     $this->assertCount(0, $section->getElements());
     // Heading
     $styles = array('strong', 'em', 'sup', 'sub');
     for ($level = 1; $level <= 6; $level++) {
         $content .= "<h{$level}>Heading {$level}</h{$level}>";
     }
     // Styles
     $content .= '<p style="text-decoration: underline; text-decoration: line-through; ' . 'text-align: center; color: #999; background-color: #000;">';
     foreach ($styles as $style) {
         $content .= "<{$style}>{$style}</{$style}>";
     }
     $content .= '</p>';
     // Add HTML
     Html::addHtml($section, $content);
     $this->assertCount(7, $section->getElements());
     // Other parts
     $section = new Section(1);
     $content = '';
     $content .= '<table><tr><th>Header</th><td>Content</td></tr></table>';
     $content .= '<ul><li>Bullet</li><ul><li>Bullet</li></ul></ul>';
     $content .= '<ol><li>Bullet</li></ol>';
     $content .= "'Single Quoted Text'";
     $content .= '"Double Quoted Text"';
     $content .= '& Ampersand';
     $content .= '&lt;&gt;&ldquo;&lsquo;&rsquo;&laquo;&raquo;&lsaquo;&rsaquo;';
     $content .= '&amp;&bull;&deg;&hellip;&trade;&copy;&reg;&mdash;';
     $content .= '&ndash;&nbsp;&emsp;&ensp;&sup2;&sup3;&frac14;&frac12;&frac34;';
     Html::addHtml($section, $content);
 }
Esempio n. 2
0
 /**
  * Add title with predefined style
  */
 public function testAddTitleWithStyle()
 {
     Style::addTitleStyle(1, array('size' => 14));
     $section = new Section(0);
     $section->addTitle('Test', 1);
     $elementCollection = $section->getElements();
     $this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\Title", $elementCollection[0]);
 }
Esempio n. 3
0
 /**
  * Add title with predefined style
  */
 public function testAddTitleWithStyle()
 {
     Style::addTitleStyle(1, array('size' => 14));
     $section = new Section(0);
     $section->setPhpWord(new PhpWord());
     $section->addTitle(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'), 1);
     $elementCollection = $section->getElements();
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Title', $elementCollection[0]);
 }