/** * This function checks that the document does not include extra * paragraphs if the wiki page starts with a table. * * Extra paragraphs without text content would cause the document to * start with an empty line(s). */ public function test_start_table() { // Render document with one table only. $files = array(); $page = "^ Heading 1 ^ Heading 2 ^ Heading 3 ^\n"; $page .= "| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |\n"; $ok = ODTTestUtils::getRenderedODTDocument($files, $page); $this->assertFalse($ok == false, 'Error rendering, creating, unpacking, reading ODT doc!'); // Examine ODT XML content. // Get office:text $office_text = XMLUtil::getElementContent('office:text', $files['content-xml']); $this->assertFalse($office_text == NULL, 'Element "office:text" not found!'); // Get first paragraph $paragraph = XMLUtil::getElementContent('text:p', $office_text); // Get first table and first table paragraph $table = XMLUtil::getElementContent('table:table', $office_text); $table_paragraph = XMLUtil::getElementContent('text:p', $table); $found = preg_match('/Heading 1/', $table_paragraph); $this->assertFalse($found != 1, "First table paragraph does not include first heading!"); $this->assertFalse($table_paragraph != $paragraph, "First table paragraph is not the first paragraph!"); }
/** * This function checks the rendering of deleted text. */ public function test_deleted_text() { $files = array(); $ok = ODTTestUtils::getRenderedODTDocument($files, '<del>This is strike-through text.</del>'); $this->assertFalse($ok == false, 'Error rendering, creating, unpacking, reading ODT doc!'); // Examine ODT XML content. // Get office:text $office_text = XMLUtil::getElementContent('office:text', $files['content-xml']); $this->assertFalse($office_text == NULL, 'Element "office:text" not found!'); // Get first paragraph $paragraph = XMLUtil::getElementContent('text:p', $office_text); $this->assertFalse($paragraph == NULL, 'Element "text:p" not found!'); // The paragraph shouild have a text span. $span_attrs = XMLUtil::getElementOpenTag('text:span', $office_text); $span_content = XMLUtil::getElementContent('text:span', $office_text); $this->assertFalse($span_content == NULL, 'Element "text:p" not found!'); // The span should have our text content and the style for bold text $this->assertEquals($span_content, 'This is strike-through text.'); $attributes = array(); $found = XMLUtil::getAttributes($attributes, $span_attrs); $this->assertEquals(1, $found); $this->assertEquals('del', $attributes['text:style-name']); }