add contents
This commit is contained in:
88
lib/plugins/odt/_test/ODTTestUtils.php
Normal file
88
lib/plugins/odt/_test/ODTTestUtils.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper class for ODT tests.
|
||||
* This class just includes utility functions and is not performing any tests.
|
||||
*/
|
||||
class ODTTestUtils {
|
||||
/**
|
||||
* This function renders $content using the ODT-page-renderer.
|
||||
* It then unzips the ODT document and reads in the file contents
|
||||
* of the files 'content.xml', 'meta.xml' and 'styles.xml' and
|
||||
* saves the strings in $files ['content-xml'], $files ['meta-xml']
|
||||
* and $files ['styles-xml'].
|
||||
*
|
||||
* @param array $files
|
||||
* @param string $content
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getRenderedODTDocument (array &$files, $content) {
|
||||
// Create parser instructions for wiki page $content
|
||||
$instructions = p_get_instructions($content);
|
||||
|
||||
// Render the page by looping through the instructions.
|
||||
$renderer = new renderer_plugin_odt_page();
|
||||
foreach ( $instructions as $instruction ) {
|
||||
// Execute the callback against the Renderer
|
||||
if(method_exists($renderer, $instruction[0])){
|
||||
call_user_func_array(array(&$renderer, $instruction[0]), $instruction[1] ? $instruction[1] : array());
|
||||
}
|
||||
}
|
||||
|
||||
io_savefile(TMP_DIR.'/odt/temp_test_doc.odt', $renderer->doc);
|
||||
try {
|
||||
$ZIPextract = new \splitbrain\PHPArchive\Zip();
|
||||
$ZIPextract->open(TMP_DIR.'/odt/temp_test_doc.odt');
|
||||
$ZIPextract->extract(TMP_DIR.'/odt/unpacked');
|
||||
} catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
|
||||
throw new Exception(' Error extracting the zip archive:'.$template.' to '.$tempDir);
|
||||
}
|
||||
|
||||
$files ['content-xml'] = file_get_contents(TMP_DIR.'/odt/unpacked/content.xml');
|
||||
$files ['meta-xml'] = file_get_contents(TMP_DIR.'/odt/unpacked/meta.xml');
|
||||
$files ['styles-xml'] = file_get_contents(TMP_DIR.'/odt/unpacked/styles.xml');
|
||||
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function "uploads" all files from $sourcedir to the destination
|
||||
* namespace $destns.
|
||||
*
|
||||
* @param string $destns Desinatio namespace, e.g. 'wiki'
|
||||
* @param string $souredir Directory which shall be copied
|
||||
* @author LarsDW223
|
||||
*/
|
||||
public static function rcopyMedia($destns, $sourcedir) {
|
||||
// Buffer all outputs generated from media_save
|
||||
ob_start();
|
||||
|
||||
// Read directory manually and call media_save for each file
|
||||
$handle = opendir($sourcedir);
|
||||
$read_res = readdir($handle);
|
||||
while ($read_res !== false) {
|
||||
if ($read_res != '.' && $read_res != '..') {
|
||||
$path = $sourcedir.'/'.$read_res;
|
||||
$ns = $destns;
|
||||
$id = $read_res;
|
||||
list($ext,$mime) = mimetype($path);
|
||||
$res = media_save(
|
||||
array('name' => $path,
|
||||
'mime' => $mime,
|
||||
'ext' => $ext),
|
||||
$ns.':'.$id,
|
||||
true,
|
||||
AUTH_UPLOAD,
|
||||
'copy'
|
||||
);
|
||||
}
|
||||
|
||||
$read_res = readdir($handle);
|
||||
}
|
||||
closedir($handle);
|
||||
|
||||
// Disable buffering and throw all outputs away
|
||||
ob_end_clean();
|
||||
}
|
||||
}
|
871
lib/plugins/odt/_test/cssimport.test.php
Normal file
871
lib/plugins/odt/_test/cssimport.test.php
Normal file
@@ -0,0 +1,871 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/helper/cssimport.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the CSS import classes.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_cssimport_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(){
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// copy CSS test files to test directory
|
||||
TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the constructur sets the right properties and the getters
|
||||
* return them correctly.
|
||||
*/
|
||||
public function test_simple_css_declaration() {
|
||||
$decl = new css_declaration ('color', 'black');
|
||||
|
||||
$this->assertEquals($decl->getProperty(), 'color');
|
||||
$this->assertEquals($decl->getValue(), 'black');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'border' is exploded correctly.
|
||||
*/
|
||||
public function test_border_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('border', '5px solid red;');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 19);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'border-width');
|
||||
$this->assertEquals($decls [0]->getValue(), '5px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'border-left-width');
|
||||
$this->assertEquals($decls [1]->getValue(), '5px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'border-right-width');
|
||||
$this->assertEquals($decls [2]->getValue(), '5px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'border-top-width');
|
||||
$this->assertEquals($decls [3]->getValue(), '5px');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'border-bottom-width');
|
||||
$this->assertEquals($decls [4]->getValue(), '5px');
|
||||
|
||||
$this->assertEquals($decls [5]->getProperty(), 'border-style');
|
||||
$this->assertEquals($decls [5]->getValue(), 'solid');
|
||||
$this->assertEquals($decls [6]->getProperty(), 'border-left-style');
|
||||
$this->assertEquals($decls [6]->getValue(), 'solid');
|
||||
$this->assertEquals($decls [7]->getProperty(), 'border-right-style');
|
||||
$this->assertEquals($decls [7]->getValue(), 'solid');
|
||||
$this->assertEquals($decls [8]->getProperty(), 'border-top-style');
|
||||
$this->assertEquals($decls [8]->getValue(), 'solid');
|
||||
$this->assertEquals($decls [9]->getProperty(), 'border-bottom-style');
|
||||
$this->assertEquals($decls [9]->getValue(), 'solid');
|
||||
|
||||
$this->assertEquals($decls [10]->getProperty(), 'border-color');
|
||||
$this->assertEquals($decls [10]->getValue(), 'red');
|
||||
$this->assertEquals($decls [11]->getProperty(), 'border-left-color');
|
||||
$this->assertEquals($decls [11]->getValue(), 'red');
|
||||
$this->assertEquals($decls [12]->getProperty(), 'border-right-color');
|
||||
$this->assertEquals($decls [12]->getValue(), 'red');
|
||||
$this->assertEquals($decls [13]->getProperty(), 'border-top-color');
|
||||
$this->assertEquals($decls [13]->getValue(), 'red');
|
||||
$this->assertEquals($decls [14]->getProperty(), 'border-bottom-color');
|
||||
$this->assertEquals($decls [14]->getValue(), 'red');
|
||||
|
||||
$this->assertEquals($decls [15]->getProperty(), 'border-left');
|
||||
$this->assertEquals($decls [15]->getValue(), '5px solid red');
|
||||
$this->assertEquals($decls [16]->getProperty(), 'border-right');
|
||||
$this->assertEquals($decls [16]->getValue(), '5px solid red');
|
||||
$this->assertEquals($decls [17]->getProperty(), 'border-top');
|
||||
$this->assertEquals($decls [17]->getValue(), '5px solid red');
|
||||
$this->assertEquals($decls [18]->getProperty(), 'border-bottom');
|
||||
$this->assertEquals($decls [18]->getValue(), '5px solid red');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'font' is exploded correctly.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_font_shorthand_1() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('font', '15px arial, sans-serif;');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 2);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'font-size');
|
||||
$this->assertEquals($decls [0]->getValue(), '15px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'font-family');
|
||||
$this->assertEquals($decls [1]->getValue(), 'arial, sans-serif');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'font' is exploded correctly.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_font_shorthand_2() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('font', 'italic bold 12px/30px Georgia, serif;');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 5);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'font-style');
|
||||
$this->assertEquals($decls [0]->getValue(), 'italic');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'font-weight');
|
||||
$this->assertEquals($decls [1]->getValue(), 'bold');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'font-size');
|
||||
$this->assertEquals($decls [2]->getValue(), '12px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'line-height');
|
||||
$this->assertEquals($decls [3]->getValue(), '30px');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'font-family');
|
||||
$this->assertEquals($decls [4]->getValue(), 'Georgia, serif');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'background' is exploded correctly.
|
||||
*/
|
||||
public function test_background_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('background', '#ffffff url("img_tree.png") no-repeat right top');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 5);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'background-color');
|
||||
$this->assertEquals($decls [0]->getValue(), '#ffffff');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'background-image');
|
||||
$this->assertEquals($decls [1]->getValue(), 'url("img_tree.png")');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'background-repeat');
|
||||
$this->assertEquals($decls [2]->getValue(), 'no-repeat');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'background-attachment');
|
||||
$this->assertEquals($decls [3]->getValue(), 'right');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'background-position');
|
||||
$this->assertEquals($decls [4]->getValue(), 'top');
|
||||
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('background', 'transparent url("img_tree.png") no-repeat right top');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 5);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'background-color');
|
||||
$this->assertEquals($decls [0]->getValue(), 'transparent');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'background-image');
|
||||
$this->assertEquals($decls [1]->getValue(), 'url("img_tree.png")');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'background-repeat');
|
||||
$this->assertEquals($decls [2]->getValue(), 'no-repeat');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'background-attachment');
|
||||
$this->assertEquals($decls [3]->getValue(), 'right');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'background-position');
|
||||
$this->assertEquals($decls [4]->getValue(), 'top');
|
||||
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('background', 'initial url("img_tree.png") no-repeat right top');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 5);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'background-color');
|
||||
$this->assertEquals($decls [0]->getValue(), 'initial');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'background-image');
|
||||
$this->assertEquals($decls [1]->getValue(), 'url("img_tree.png")');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'background-repeat');
|
||||
$this->assertEquals($decls [2]->getValue(), 'no-repeat');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'background-attachment');
|
||||
$this->assertEquals($decls [3]->getValue(), 'right');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'background-position');
|
||||
$this->assertEquals($decls [4]->getValue(), 'top');
|
||||
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('background', 'inherit url("img_tree.png") no-repeat right top');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 5);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'background-color');
|
||||
$this->assertEquals($decls [0]->getValue(), 'inherit');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'background-image');
|
||||
$this->assertEquals($decls [1]->getValue(), 'url("img_tree.png")');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'background-repeat');
|
||||
$this->assertEquals($decls [2]->getValue(), 'no-repeat');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'background-attachment');
|
||||
$this->assertEquals($decls [3]->getValue(), 'right');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'background-position');
|
||||
$this->assertEquals($decls [4]->getValue(), 'top');
|
||||
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('background', 'url("img_tree.png") no-repeat right top');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'background-image');
|
||||
$this->assertEquals($decls [0]->getValue(), 'url("img_tree.png")');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'background-repeat');
|
||||
$this->assertEquals($decls [1]->getValue(), 'no-repeat');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'background-attachment');
|
||||
$this->assertEquals($decls [2]->getValue(), 'right');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'background-position');
|
||||
$this->assertEquals($decls [3]->getValue(), 'top');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'padding' is exploded correctly.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_padding_shorthand_1() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('padding', '25px 50px 75px 100px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'padding-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'padding-right');
|
||||
$this->assertEquals($decls [1]->getValue(), '50px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'padding-bottom');
|
||||
$this->assertEquals($decls [2]->getValue(), '75px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'padding-left');
|
||||
$this->assertEquals($decls [3]->getValue(), '100px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'padding' is exploded correctly.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_padding_shorthand_2() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('padding', '25px 50px 75px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'padding-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'padding-right');
|
||||
$this->assertEquals($decls [1]->getValue(), '50px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'padding-left');
|
||||
$this->assertEquals($decls [2]->getValue(), '50px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'padding-bottom');
|
||||
$this->assertEquals($decls [3]->getValue(), '75px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'padding' is exploded correctly.
|
||||
* Part 3.
|
||||
*/
|
||||
public function test_padding_shorthand_3() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('padding', '25px 50px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'padding-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'padding-bottom');
|
||||
$this->assertEquals($decls [1]->getValue(), '25px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'padding-right');
|
||||
$this->assertEquals($decls [2]->getValue(), '50px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'padding-left');
|
||||
$this->assertEquals($decls [3]->getValue(), '50px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'padding' is exploded correctly.
|
||||
* Part 4.
|
||||
*/
|
||||
public function test_padding_shorthand_4() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('padding', '25px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'padding-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'padding-bottom');
|
||||
$this->assertEquals($decls [1]->getValue(), '25px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'padding-right');
|
||||
$this->assertEquals($decls [2]->getValue(), '25px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'padding-left');
|
||||
$this->assertEquals($decls [3]->getValue(), '25px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'margin' is exploded correctly.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_margin_shorthand_1() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('margin', '25px 50px 75px 100px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'margin-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'margin-right');
|
||||
$this->assertEquals($decls [1]->getValue(), '50px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'margin-bottom');
|
||||
$this->assertEquals($decls [2]->getValue(), '75px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'margin-left');
|
||||
$this->assertEquals($decls [3]->getValue(), '100px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'margin' is exploded correctly.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_margin_shorthand_2() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('margin', '25px 50px 75px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'margin-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'margin-right');
|
||||
$this->assertEquals($decls [1]->getValue(), '50px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'margin-left');
|
||||
$this->assertEquals($decls [2]->getValue(), '50px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'margin-bottom');
|
||||
$this->assertEquals($decls [3]->getValue(), '75px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'margin' is exploded correctly.
|
||||
* Part 3.
|
||||
*/
|
||||
public function test_margin_shorthand_3() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('margin', '25px 50px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'margin-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'margin-bottom');
|
||||
$this->assertEquals($decls [1]->getValue(), '25px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'margin-right');
|
||||
$this->assertEquals($decls [2]->getValue(), '50px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'margin-left');
|
||||
$this->assertEquals($decls [3]->getValue(), '50px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'margin' is exploded correctly.
|
||||
* Part 4.
|
||||
*/
|
||||
public function test_margin_shorthand_4() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('margin', '25px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'margin-top');
|
||||
$this->assertEquals($decls [0]->getValue(), '25px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'margin-bottom');
|
||||
$this->assertEquals($decls [1]->getValue(), '25px');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'margin-right');
|
||||
$this->assertEquals($decls [2]->getValue(), '25px');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'margin-left');
|
||||
$this->assertEquals($decls [3]->getValue(), '25px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'list-style' is exploded correctly.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_list_style_shorthand_1() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('list-style', 'square url("sqpurple.gif");');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 3);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'list-style-type');
|
||||
$this->assertEquals($decls [0]->getValue(), 'square');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'list-style-position');
|
||||
$this->assertEquals($decls [1]->getValue(), 'outside');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'list-style-image');
|
||||
$this->assertEquals($decls [2]->getValue(), 'url("sqpurple.gif")');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'list-style' is exploded correctly.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_list_style_shorthand_2() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('list-style', 'square inside url("sqpurple.gif");');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 3);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'list-style-type');
|
||||
$this->assertEquals($decls [0]->getValue(), 'square');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'list-style-position');
|
||||
$this->assertEquals($decls [1]->getValue(), 'inside');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'list-style-image');
|
||||
$this->assertEquals($decls [2]->getValue(), 'url("sqpurple.gif")');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'flex' is exploded correctly.
|
||||
*/
|
||||
public function test_flex_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('flex', '1 2 200px');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 3);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'flex-grow');
|
||||
$this->assertEquals($decls [0]->getValue(), '1');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'flex-shrink');
|
||||
$this->assertEquals($decls [1]->getValue(), '2');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'flex-basis');
|
||||
$this->assertEquals($decls [2]->getValue(), '200px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'transition' is exploded correctly.
|
||||
*/
|
||||
public function test_transition_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('transition', 'width 2s linear 1s');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 4);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'transition-property');
|
||||
$this->assertEquals($decls [0]->getValue(), 'width');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'transition-duration');
|
||||
$this->assertEquals($decls [1]->getValue(), '2s');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'transition-timing-function');
|
||||
$this->assertEquals($decls [2]->getValue(), 'linear');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'transition-delay');
|
||||
$this->assertEquals($decls [3]->getValue(), '1s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'outline' is exploded correctly.
|
||||
*/
|
||||
public function test_outline_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('outline', '#00FF00 dotted thick');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 3);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'outline-color');
|
||||
$this->assertEquals($decls [0]->getValue(), '#00FF00');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'outline-style');
|
||||
$this->assertEquals($decls [1]->getValue(), 'dotted');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'outline-width');
|
||||
$this->assertEquals($decls [2]->getValue(), 'thick');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'animation' is exploded correctly.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_animation_shorthand_1() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('animation', 'mymove 5s infinite;');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 3);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'animation-name');
|
||||
$this->assertEquals($decls [0]->getValue(), 'mymove');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'animation-duration');
|
||||
$this->assertEquals($decls [1]->getValue(), '5s');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'animation-timing-function');
|
||||
$this->assertEquals($decls [2]->getValue(), 'infinite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'animation' is exploded correctly.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_animation_shorthand_2() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('animation', 'mymove 5s infinite 2s 3 normal forwards paused;');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 8);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'animation-name');
|
||||
$this->assertEquals($decls [0]->getValue(), 'mymove');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'animation-duration');
|
||||
$this->assertEquals($decls [1]->getValue(), '5s');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'animation-timing-function');
|
||||
$this->assertEquals($decls [2]->getValue(), 'infinite');
|
||||
$this->assertEquals($decls [3]->getProperty(), 'animation-delay');
|
||||
$this->assertEquals($decls [3]->getValue(), '2s');
|
||||
$this->assertEquals($decls [4]->getProperty(), 'animation-iteration-count');
|
||||
$this->assertEquals($decls [4]->getValue(), '3');
|
||||
$this->assertEquals($decls [5]->getProperty(), 'animation-direction');
|
||||
$this->assertEquals($decls [5]->getValue(), 'normal');
|
||||
$this->assertEquals($decls [6]->getProperty(), 'animation-fill-mode');
|
||||
$this->assertEquals($decls [6]->getValue(), 'forwards');
|
||||
$this->assertEquals($decls [7]->getProperty(), 'animation-play-state');
|
||||
$this->assertEquals($decls [7]->getValue(), 'paused');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'border-bottom' is exploded correctly.
|
||||
*/
|
||||
public function test_border_bottom_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('border-bottom', 'thick dotted #ff0000;');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 3);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'border-bottom-width');
|
||||
$this->assertEquals($decls [0]->getValue(), 'thick');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'border-bottom-style');
|
||||
$this->assertEquals($decls [1]->getValue(), 'dotted');
|
||||
$this->assertEquals($decls [2]->getProperty(), 'border-bottom-color');
|
||||
$this->assertEquals($decls [2]->getValue(), '#ff0000');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the shorthand 'columns' is exploded correctly.
|
||||
*/
|
||||
public function test_columns_shorthand() {
|
||||
/** @var css_declaration[] $decls */
|
||||
$decls = array();
|
||||
$decl = new css_declaration ('columns', '100px 3');
|
||||
$decl->explode ($decls);
|
||||
|
||||
$this->assertEquals(count($decls), 2);
|
||||
$this->assertEquals($decls [0]->getProperty(), 'column-width');
|
||||
$this->assertEquals($decls [0]->getValue(), '100px');
|
||||
$this->assertEquals($decls [1]->getProperty(), 'column-count');
|
||||
$this->assertEquals($decls [1]->getValue(), '3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that @media queries are understood.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_media_queries_part1() {
|
||||
$properties = array();
|
||||
$css_code = 'p {
|
||||
background-color:blue;
|
||||
}
|
||||
|
||||
@media print {
|
||||
p {
|
||||
background-color:white;
|
||||
}
|
||||
}';
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromString ($css_code);
|
||||
$import->getPropertiesForElement ($properties, 'p', NULL);
|
||||
|
||||
// Only for debugging.
|
||||
//print ($import->rulesToString());
|
||||
|
||||
$this->assertEquals(count($properties), 1);
|
||||
$this->assertEquals('blue', $properties ['background-color']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that @media queries are understood.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_media_queries_part2() {
|
||||
$properties = array();
|
||||
$css_code = 'p {
|
||||
background-color:blue;
|
||||
}
|
||||
|
||||
@media print {
|
||||
p {
|
||||
background-color:white;
|
||||
}
|
||||
}';
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromString ($css_code);
|
||||
$import->getPropertiesForElement ($properties, 'p', NULL, 'print');
|
||||
|
||||
$this->assertEquals(count($properties), 1);
|
||||
$this->assertEquals('white', $properties ['background-color']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that @media queries are understood.
|
||||
* Part 3.
|
||||
*/
|
||||
public function test_media_queries_part3() {
|
||||
$properties = array();
|
||||
$css_code = '@media only screen and (max-width: 500px) {
|
||||
p {
|
||||
background-color:blue;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
p {
|
||||
background-color:white;
|
||||
}
|
||||
}';
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromString ($css_code);
|
||||
$import->getPropertiesForElement ($properties, 'p', NULL);
|
||||
|
||||
// We shouldn't get any properties
|
||||
$this->assertEquals(0, count($properties));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that @media queries are understood.
|
||||
* Part 4.
|
||||
*/
|
||||
public function test_media_queries_part4() {
|
||||
$properties = array();
|
||||
$css_code = '@media screen {
|
||||
p {
|
||||
background-color:blue;
|
||||
}
|
||||
|
||||
p {
|
||||
color:red;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
p {
|
||||
background-color:white;
|
||||
}
|
||||
}';
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromString ($css_code);
|
||||
$import->getPropertiesForElement ($properties, 'p', NULL, 'print');
|
||||
|
||||
// Check properties
|
||||
$this->assertEquals(1, count($properties));
|
||||
$this->assertEquals('white', $properties ['background-color']);
|
||||
$this->assertEquals(NULL, $properties ['color']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test more complicated CSS parsing with dw and wrap CSS.
|
||||
* Part 1.
|
||||
*/
|
||||
public function test_dw_and_wrap_css_part1 () {
|
||||
$properties = array();
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromFile (TMP_DIR . '/data/dw_css_with_wrap.css');
|
||||
$import->getPropertiesForElement ($properties, 'div', 'dokuwiki wrap_help', 'only screen and (max-width: 600px)');
|
||||
|
||||
// For debugging: this will write the parsed/imported CSS in the file
|
||||
// /tmp/dwtests-xxx.yyy/data/odt_parsed.css
|
||||
//$handle = fopen (TMP_DIR . '/data/odt_parsed.css', 'w');
|
||||
//fwrite ($handle, $import->rulesToString());
|
||||
//fclose ($handle);
|
||||
|
||||
// Check properties
|
||||
$this->assertEquals(33, count($properties));
|
||||
$this->assertEquals('1em 1em .5em', $properties ['padding']);
|
||||
$this->assertEquals('1em', $properties ['padding-top']);
|
||||
$this->assertEquals('1em', $properties ['padding-right']);
|
||||
$this->assertEquals('.5em', $properties ['padding-bottom']);
|
||||
$this->assertEquals('1em', $properties ['padding-left']);
|
||||
$this->assertEquals('1.5em', $properties ['margin-bottom']);
|
||||
$this->assertEquals('68px', $properties ['min-height']);
|
||||
$this->assertEquals('10px 50%', $properties ['background-position']);
|
||||
$this->assertEquals('no-repeat', $properties ['background-repeat']);
|
||||
$this->assertEquals('inherit', $properties ['color']);
|
||||
$this->assertEquals('hidden', $properties ['overflow']);
|
||||
$this->assertEquals('#dcc2ef', $properties ['background-color']);
|
||||
$this->assertEquals('url(/lib/plugins/wrap/images/note/48/help.png)', $properties ['background-image']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-left']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-right']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-top']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-bottom']);
|
||||
$this->assertEquals('2px', $properties ['border-width']);
|
||||
$this->assertEquals('2px', $properties ['border-left-width']);
|
||||
$this->assertEquals('2px', $properties ['border-right-width']);
|
||||
$this->assertEquals('2px', $properties ['border-top-width']);
|
||||
$this->assertEquals('2px', $properties ['border-bottom-width']);
|
||||
$this->assertEquals('solid', $properties ['border-style']);
|
||||
$this->assertEquals('solid', $properties ['border-left-style']);
|
||||
$this->assertEquals('solid', $properties ['border-right-style']);
|
||||
$this->assertEquals('solid', $properties ['border-top-style']);
|
||||
$this->assertEquals('solid', $properties ['border-bottom-style']);
|
||||
$this->assertEquals('#999', $properties ['border-color']);
|
||||
$this->assertEquals('#999', $properties ['border-left-color']);
|
||||
$this->assertEquals('#999', $properties ['border-right-color']);
|
||||
$this->assertEquals('#999', $properties ['border-top-color']);
|
||||
$this->assertEquals('#999', $properties ['border-bottom-color']);
|
||||
$this->assertEquals('', $properties ['']);
|
||||
$this->assertEquals('1.5em', $properties ['margin-bottom']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test more complicated CSS parsing with dw and wrap CSS.
|
||||
* Part 2.
|
||||
*/
|
||||
public function test_dw_and_wrap_css_part2 () {
|
||||
$properties = array();
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromFile (TMP_DIR . '/data/dw_css_without_extra_wrap.css');
|
||||
$import->getPropertiesForElement ($properties, 'div', 'dokuwiki wrap_help', 'print');
|
||||
|
||||
// For debugging: this will write the parsed/imported CSS in the file
|
||||
// /tmp/dwtests-xxx.yyy/data/odt_parsed.css
|
||||
//$handle = fopen (TMP_DIR . '/data/odt_parsed.css', 'w');
|
||||
//fwrite ($handle, $import->rulesToString());
|
||||
//fclose ($handle);
|
||||
|
||||
// Check properties
|
||||
$this->assertEquals(26, count($properties));
|
||||
$this->assertEquals('2px solid #999', $properties ['border']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-left']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-right']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-top']);
|
||||
$this->assertEquals('2px solid #999', $properties ['border-bottom']);
|
||||
$this->assertEquals('2px', $properties ['border-width']);
|
||||
$this->assertEquals('2px', $properties ['border-left-width']);
|
||||
$this->assertEquals('2px', $properties ['border-right-width']);
|
||||
$this->assertEquals('2px', $properties ['border-top-width']);
|
||||
$this->assertEquals('2px', $properties ['border-bottom-width']);
|
||||
$this->assertEquals('solid', $properties ['border-style']);
|
||||
$this->assertEquals('solid', $properties ['border-left-style']);
|
||||
$this->assertEquals('solid', $properties ['border-right-style']);
|
||||
$this->assertEquals('solid', $properties ['border-top-style']);
|
||||
$this->assertEquals('solid', $properties ['border-bottom-style']);
|
||||
$this->assertEquals('#999', $properties ['border-color']);
|
||||
$this->assertEquals('#999', $properties ['border-left-color']);
|
||||
$this->assertEquals('#999', $properties ['border-right-color']);
|
||||
$this->assertEquals('#999', $properties ['border-top-color']);
|
||||
$this->assertEquals('#999', $properties ['border-bottom-color']);
|
||||
$this->assertEquals('1em 1em .5em', $properties ['padding']);
|
||||
$this->assertEquals('1em', $properties ['padding-top']);
|
||||
$this->assertEquals('1em', $properties ['padding-right']);
|
||||
$this->assertEquals('1em', $properties ['padding-left']);
|
||||
$this->assertEquals('.5em', $properties ['padding-bottom']);
|
||||
$this->assertEquals('1.5em', $properties ['margin-bottom']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test some more wrap CSS.
|
||||
* Part 3.
|
||||
*/
|
||||
public function test_wrap_css() {
|
||||
$properties = array();
|
||||
$css_code = '/*____________ help ____________*/
|
||||
.dokuwiki .wrap_help { background-color: #dcc2ef; }
|
||||
.dokuwiki .wrap__dark.wrap_help { background-color: #3c1757; }
|
||||
.dokuwiki div.wrap_help { background-image: url(images/note/48/help.png); }
|
||||
.dokuwiki span.wrap_help { background-image: url(images/note/16/help.png); }';
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromString ($css_code);
|
||||
$import->getPropertiesForElement ($properties, 'div', 'dokuwiki wrap_help');
|
||||
|
||||
// For debugging: this will write the parsed/imported CSS in the file
|
||||
// /tmp/dwtests-xxx.yyy/data/odt_parsed.css
|
||||
//$handle = fopen (TMP_DIR . '/data/odt_parsed.css', 'w');
|
||||
//fwrite ($handle, $import->rulesToString());
|
||||
//fclose ($handle);
|
||||
|
||||
// We shouldn't get any properties
|
||||
$this->assertEquals(2, count($properties));
|
||||
$this->assertEquals('#dcc2ef', $properties ['background-color']);
|
||||
$this->assertEquals('url(images/note/48/help.png)', $properties ['background-image']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test some more wrap CSS.
|
||||
* Part 4.
|
||||
*/
|
||||
public function test_wrap_css_part2() {
|
||||
$properties = array();
|
||||
$css_code = '@media screen {
|
||||
/*____________ help ____________*/
|
||||
.dokuwiki .wrap_help { background-color: #dcc2ef; }
|
||||
.dokuwiki .wrap__dark.wrap_help { background-color: #3c1757; }
|
||||
.dokuwiki div.wrap_help { background-image: url(images/note/48/help.png); }
|
||||
.dokuwiki span.wrap_help { background-image: url(images/note/16/help.png); }
|
||||
}
|
||||
@media print {
|
||||
/* boxes and notes with icons
|
||||
********************************************************************/
|
||||
|
||||
.dokuwiki div.wrap_box,
|
||||
.dokuwiki div.wrap_danger, .dokuwiki div.wrap_warning, .dokuwiki div.wrap_caution, .dokuwiki div.wrap_notice, .dokuwiki div.wrap_safety,
|
||||
.dokuwiki div.wrap_info, .dokuwiki div.wrap_important, .dokuwiki div.wrap_alert, .dokuwiki div.wrap_tip, .dokuwiki div.wrap_help, .dokuwiki div.wrap_todo, .dokuwiki div.wrap_download {
|
||||
border: 2px solid #999;
|
||||
padding: 1em 1em .5em;
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
.dokuwiki span.wrap_box,
|
||||
.dokuwiki span.wrap_danger, .dokuwiki span.wrap_warning, .dokuwiki span.wrap_caution, .dokuwiki span.wrap_notice, .dokuwiki span.wrap_safety,
|
||||
.dokuwiki span.wrap_info, .dokuwiki span.wrap_important, .dokuwiki span.wrap_alert, .dokuwiki span.wrap_tip, .dokuwiki span.wrap_help, .dokuwiki span.wrap_todo, .dokuwiki span.wrap_download {
|
||||
border: 1px solid #999;
|
||||
padding: 0 .3em;
|
||||
}
|
||||
}';
|
||||
|
||||
$import = new helper_plugin_odt_cssimport ();
|
||||
$import->importFromString ($css_code);
|
||||
$import->getPropertiesForElement ($properties, 'span', 'dokuwiki wrap_help', 'print');
|
||||
|
||||
// For debugging: this will write the parsed/imported CSS in the file
|
||||
// /tmp/dwtests-xxx.yyy/data/odt_parsed.css
|
||||
$handle = fopen (TMP_DIR . '/data/odt_parsed.css', 'w');
|
||||
fwrite ($handle, $import->rulesToString());
|
||||
fclose ($handle);
|
||||
|
||||
// We shouldn't get any properties
|
||||
$this->assertEquals(25, count($properties));
|
||||
$this->assertEquals('1px solid #999', $properties ['border']);
|
||||
$this->assertEquals('1px solid #999', $properties ['border-left']);
|
||||
$this->assertEquals('1px solid #999', $properties ['border-right']);
|
||||
$this->assertEquals('1px solid #999', $properties ['border-top']);
|
||||
$this->assertEquals('1px solid #999', $properties ['border-bottom']);
|
||||
$this->assertEquals('1px', $properties ['border-width']);
|
||||
$this->assertEquals('1px', $properties ['border-left-width']);
|
||||
$this->assertEquals('1px', $properties ['border-right-width']);
|
||||
$this->assertEquals('1px', $properties ['border-top-width']);
|
||||
$this->assertEquals('1px', $properties ['border-bottom-width']);
|
||||
$this->assertEquals('solid', $properties ['border-style']);
|
||||
$this->assertEquals('solid', $properties ['border-left-style']);
|
||||
$this->assertEquals('solid', $properties ['border-right-style']);
|
||||
$this->assertEquals('solid', $properties ['border-top-style']);
|
||||
$this->assertEquals('solid', $properties ['border-bottom-style']);
|
||||
$this->assertEquals('#999', $properties ['border-color']);
|
||||
$this->assertEquals('#999', $properties ['border-left-color']);
|
||||
$this->assertEquals('#999', $properties ['border-right-color']);
|
||||
$this->assertEquals('#999', $properties ['border-top-color']);
|
||||
$this->assertEquals('#999', $properties ['border-bottom-color']);
|
||||
$this->assertEquals('0 .3em', $properties ['padding']);
|
||||
$this->assertEquals('0', $properties ['padding-top']);
|
||||
$this->assertEquals('.3em', $properties ['padding-right']);
|
||||
$this->assertEquals('.3em', $properties ['padding-left']);
|
||||
$this->assertEquals('0', $properties ['padding-bottom']);
|
||||
}
|
||||
}
|
1517
lib/plugins/odt/_test/cssimportnew.test.php
Normal file
1517
lib/plugins/odt/_test/cssimportnew.test.php
Normal file
File diff suppressed because it is too large
Load Diff
1
lib/plugins/odt/_test/data/dw_css_with_wrap.css
Normal file
1
lib/plugins/odt/_test/data/dw_css_with_wrap.css
Normal file
File diff suppressed because one or more lines are too long
1
lib/plugins/odt/_test/data/dw_css_without_extra_wrap.css
Normal file
1
lib/plugins/odt/_test/data/dw_css_without_extra_wrap.css
Normal file
File diff suppressed because one or more lines are too long
BIN
lib/plugins/odt/_test/data/media/wiki/TestPicture100x50.png
Normal file
BIN
lib/plugins/odt/_test/data/media/wiki/TestPicture100x50.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 961 B |
BIN
lib/plugins/odt/_test/data/media/wiki/TestPicture500x256.png
Normal file
BIN
lib/plugins/odt/_test/data/media/wiki/TestPicture500x256.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
304
lib/plugins/odt/_test/odt.styles.paragraphstyle.test.php
Normal file
304
lib/plugins/odt/_test/odt.styles.paragraphstyle.test.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for Paragraph style.
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author LarsDW223
|
||||
* @package Tests\Styles\TextListStyle
|
||||
*/
|
||||
|
||||
/** Include ODTStyle */
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTParagraphStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_paragraphstyle_test extends DokuWikiTest {
|
||||
/**
|
||||
* Setup.
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/>
|
||||
<style:text-properties style:font-name="Bitstream Vera Sans1" fo:font-size="14pt" style:font-name-asian="Bitstream Vera Sans2" style:font-size-asian="14pt" style:font-name-complex="Bitstream Vera Sans2" style:font-size-complex="14pt"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$this->assertEquals($style->getFamily(), 'paragraph');
|
||||
$this->assertEquals($style->getProperty('style-name'), 'Heading');
|
||||
$this->assertEquals($style->getProperty('style-family'), 'paragraph');
|
||||
$this->assertEquals($style->getProperty('style-parent'), 'Standard');
|
||||
$this->assertEquals($style->getProperty('style-next'), 'Text_20_body');
|
||||
$this->assertEquals($style->getProperty('style-class'), 'text');
|
||||
$this->assertEquals($style->getProperty('margin-top'), '0.423cm');
|
||||
$this->assertEquals($style->getProperty('margin-bottom'), '0.212cm');
|
||||
$this->assertEquals($style->getProperty('keep-with-next'), 'always');
|
||||
$this->assertEquals($style->getProperty('font-name'), 'Bitstream Vera Sans1');
|
||||
$this->assertEquals($style->getProperty('font-size'), '14pt');
|
||||
$this->assertEquals($style->getProperty('font-name-asian'), 'Bitstream Vera Sans2');
|
||||
$this->assertEquals($style->getProperty('font-size-asian'), '14pt');
|
||||
$this->assertEquals($style->getProperty('font-name-complex'), 'Bitstream Vera Sans2');
|
||||
$this->assertEquals($style->getProperty('font-size-complex'), '14pt');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/>
|
||||
<style:text-properties style:font-name="Bitstream Vera Sans1" fo:font-size="14pt" style:font-name-asian="Bitstream Vera Sans2" style:font-size-asian="14pt" style:font-name-complex="Bitstream Vera Sans2" style:font-size-complex="14pt"/>
|
||||
</style:style>';
|
||||
// The order of attributes will change! This is OK.
|
||||
$expected = '<style:style style:name="Heading" style:parent-style-name="Standard" style:class="text" style:next-style-name="Text_20_body" style:family="paragraph" >'."\n";
|
||||
$expected .= '<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always" />'."\n";
|
||||
$expected .= '<style:text-properties fo:font-size="14pt" style:font-size-asian="14pt" style:font-size-complex="14pt" style:font-name="Bitstream Vera Sans1" style:font-name-asian="Bitstream Vera Sans2" style:font-name-complex="Bitstream Vera Sans2" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/>
|
||||
<style:text-properties style:font-name="Bitstream Vera Sans1" fo:font-size="14pt" style:font-name-asian="Bitstream Vera Sans2" style:font-size-asian="14pt" style:font-name-complex="Bitstream Vera Sans2" style:font-size-complex="14pt"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setProperty('margin-top', '999cm');
|
||||
|
||||
$this->assertEquals($style->getProperty('margin-top'), '999cm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties import and conversion to string.
|
||||
*/
|
||||
public function test_import_properties_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'Heading';
|
||||
$properties ['style-parent'] = 'Standard';
|
||||
$properties ['style-class'] = 'text';
|
||||
$properties ['style-family'] = 'paragraph';
|
||||
$properties ['style-next'] = 'Text_20_body';
|
||||
$properties ['margin-top'] = '0.423cm';
|
||||
$properties ['margin-bottom'] = '0.212cm';
|
||||
$properties ['keep-with-next'] = 'always';
|
||||
$properties ['font-size'] = '14pt';
|
||||
$properties ['font-size-asian'] = '14pt';
|
||||
$properties ['font-size-complex'] = '14pt';
|
||||
$properties ['font-name'] = 'Bitstream Vera Sans1';
|
||||
$properties ['font-name-asian'] = 'Bitstream Vera Sans2';
|
||||
$properties ['font-name-complex'] = 'Bitstream Vera Sans2';
|
||||
|
||||
$expected = '<style:style style:name="Heading" style:parent-style-name="Standard" style:class="text" style:next-style-name="Text_20_body" style:family="paragraph" >'."\n";
|
||||
$expected .= '<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always" />'."\n";
|
||||
$expected .= '<style:text-properties fo:font-size="14pt" style:font-size-asian="14pt" style:font-size-complex="14pt" style:font-name="Bitstream Vera Sans1" style:font-name-asian="Bitstream Vera Sans2" style:font-name-complex="Bitstream Vera Sans2" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTParagraphStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->importProperties($properties, NULL);
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string_default() {
|
||||
$xml_code = '<style:default-style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text">
|
||||
<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/>
|
||||
<style:text-properties style:font-name="Bitstream Vera Sans1" fo:font-size="14pt" style:font-name-asian="Bitstream Vera Sans2" style:font-size-asian="14pt" style:font-name-complex="Bitstream Vera Sans2" style:font-size-complex="14pt"/>
|
||||
</style:default-style>';
|
||||
// The order of attributes will change! This is OK.
|
||||
$expected = '<style:default-style style:name="Heading" style:parent-style-name="Standard" style:class="text" style:next-style-name="Text_20_body" style:family="paragraph" >'."\n";
|
||||
$expected .= '<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always" />'."\n";
|
||||
$expected .= '<style:text-properties fo:font-size="14pt" style:font-size-asian="14pt" style:font-size-complex="14pt" style:font-name="Bitstream Vera Sans1" style:font-name-asian="Bitstream Vera Sans2" style:font-name-complex="Bitstream Vera Sans2" />'."\n";
|
||||
$expected .= '</style:default-style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals(true, $style->isDefault());
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setProperty() and toString().
|
||||
* This is a test case for issue #120.
|
||||
*/
|
||||
public function test_set_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'Heading';
|
||||
$properties ['style-parent'] = 'Standard';
|
||||
$properties ['style-class'] = 'text';
|
||||
$properties ['style-next'] = 'Text_20_body';
|
||||
$properties ['margin-top'] = '0.423cm';
|
||||
$properties ['margin-bottom'] = '0.212cm';
|
||||
$properties ['keep-with-next'] = 'always';
|
||||
$properties ['font-size'] = '14pt';
|
||||
$properties ['font-size-asian'] = '14pt';
|
||||
$properties ['font-size-complex'] = '14pt';
|
||||
$properties ['font-name'] = 'Bitstream Vera Sans1';
|
||||
$properties ['font-name-asian'] = 'Bitstream Vera Sans2';
|
||||
$properties ['font-name-complex'] = 'Bitstream Vera Sans2';
|
||||
|
||||
$expected = '<style:style style:name="Heading" style:parent-style-name="Standard" style:class="text" style:next-style-name="Text_20_body" style:family="paragraph" >'."\n";
|
||||
$expected .= '<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always" />'."\n";
|
||||
$expected .= '<style:text-properties fo:font-size="14pt" style:font-size-asian="14pt" style:font-size-complex="14pt" style:font-name="Bitstream Vera Sans1" style:font-name-asian="Bitstream Vera Sans2" style:font-name-complex="Bitstream Vera Sans2" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTParagraphStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$style->setProperty($key, $value);
|
||||
}
|
||||
$style_string = $style->toString();
|
||||
|
||||
// We should have the following elements:
|
||||
// style:style, style:paragraph-properties, style:text-properties
|
||||
$style_style = XMLUtil::getElementOpenTag('style:style', $style_string);
|
||||
$this->assertNotNull($style_style);
|
||||
$paragraph_props = XMLUtil::getElementOpenTag('style:paragraph-properties', $style_string);
|
||||
$this->assertNotNull($paragraph_props);
|
||||
$text_props = XMLUtil::getElementOpenTag('style:text-properties', $style_string);
|
||||
$this->assertNotNull($text_props);
|
||||
|
||||
// Check attribute values of element "style:style", see $expected
|
||||
// Remark: attribute 'style:family' must always be present even if it was not set
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $style_style);
|
||||
$this->assertEquals(5, $found);
|
||||
$this->assertEquals('Heading', $attributes['style:name']);
|
||||
$this->assertEquals('Standard', $attributes['style:parent-style-name']);
|
||||
$this->assertEquals('text', $attributes['style:class']);
|
||||
$this->assertEquals('Text_20_body', $attributes['style:next-style-name']);
|
||||
$this->assertEquals('paragraph', $attributes['style:family']);
|
||||
|
||||
// Check attribute values of element "style:paragraph-properties", see $expected
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $paragraph_props);
|
||||
$this->assertEquals(3, $found);
|
||||
$this->assertEquals('0.423cm', $attributes['fo:margin-top']);
|
||||
$this->assertEquals('0.212cm', $attributes['fo:margin-bottom']);
|
||||
$this->assertEquals('always', $attributes['fo:keep-with-next']);
|
||||
|
||||
// Check attribute values of element "style:text-properties", see $expected
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $text_props);
|
||||
$this->assertEquals(6, $found);
|
||||
$this->assertEquals('14pt', $attributes['fo:font-size']);
|
||||
$this->assertEquals('14pt', $attributes['style:font-size-asian']);
|
||||
$this->assertEquals('14pt', $attributes['style:font-size-complex']);
|
||||
$this->assertEquals('Bitstream Vera Sans1', $attributes['style:font-name']);
|
||||
$this->assertEquals('Bitstream Vera Sans2', $attributes['style:font-name-asian']);
|
||||
$this->assertEquals('Bitstream Vera Sans2', $attributes['style:font-name-complex']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setProperty() and toString(), including tab-stops.
|
||||
* This is a test case for issue #123.
|
||||
*/
|
||||
public function test_set_toc_paragraph() {
|
||||
$indent = 2;
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'TOC-Test';
|
||||
$properties ['style-parent'] = 'Index';
|
||||
$properties ['style-class'] = 'index';
|
||||
$properties ['style-position'] = 17 - $indent .'cm';
|
||||
$properties ['style-type'] = 'right';
|
||||
$properties ['style-leader-style'] = 'dotted';
|
||||
$properties ['style-leader-text'] = '.';
|
||||
$properties ['margin-left'] = $indent.'cm';
|
||||
$properties ['margin-right'] = '0cm';
|
||||
$properties ['text-indent'] = '0cm';
|
||||
|
||||
// This variable is just used to show the expected result but is not used for test comparsion.
|
||||
// We explicitly parse the exported XML code to be independent from attributes position.
|
||||
// The attrbitues positions might change in the future if ODTParagraphStyle.php is changed.
|
||||
$expected = '<style:style style:name="TOC-Test" style:parent-style-name="Index" style:class="index" style:family="paragraph" >';
|
||||
$expected .= '<style:paragraph-properties fo:margin-left="2cm" fo:margin-right="0cm" fo:text-indent="0cm" >';
|
||||
$expected .= '<style:tab-stops>';
|
||||
$expected .= '<style:tab-stop style:position="15cm" style:type="right" style:leader-style="dotted" style:leader-text="." />';
|
||||
$expected .= '</style:tab-stops>';
|
||||
$expected .= '</style:paragraph-properties>';
|
||||
$expected .= '</style:style>';
|
||||
|
||||
// Create style, set all properties and get XML code of the style
|
||||
$style = new ODTParagraphStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$style->setProperty($key, $value);
|
||||
}
|
||||
$style_string = $style->toString();
|
||||
|
||||
// We should have the following elements:
|
||||
// style:style, style:paragraph-properties, style:text-properties, style:tab-stops
|
||||
$style_style = XMLUtil::getElementOpenTag('style:style', $style_string);
|
||||
$this->assertNotNull($style_style);
|
||||
$paragraph_props = XMLUtil::getElementOpenTag('style:paragraph-properties', $style_string);
|
||||
$paragraph = XMLUtil::getElement('style:paragraph-properties', $style_string);
|
||||
$this->assertNotNull($paragraph_props);
|
||||
$tab_stops_props = XMLUtil::getElement('style:tab-stops', $paragraph);
|
||||
$this->assertNotNull($tab_stops_props);
|
||||
$tab_stop_props = XMLUtil::getElementOpenTag('style:tab-stop', $tab_stops_props);
|
||||
$this->assertNotNull($tab_stop_props);
|
||||
|
||||
// Check attribute values of element "style:style", see $expected
|
||||
// Remark: attribute 'style:family' must always be present even if it was not set
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $style_style);
|
||||
$this->assertEquals(4, $found);
|
||||
$this->assertEquals('TOC-Test', $attributes['style:name']);
|
||||
$this->assertEquals('Index', $attributes['style:parent-style-name']);
|
||||
$this->assertEquals('index', $attributes['style:class']);
|
||||
$this->assertEquals('paragraph', $attributes['style:family']);
|
||||
|
||||
// Check attribute values of element "style:paragraph-properties", see $expected
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $paragraph_props);
|
||||
$this->assertEquals(3, $found);
|
||||
$this->assertEquals('2cm', $attributes['fo:margin-left']);
|
||||
$this->assertEquals('0cm', $attributes['fo:margin-right']);
|
||||
$this->assertEquals('0cm', $attributes['fo:text-indent']);
|
||||
|
||||
// Check attribute values of element "style:tab-stop", see $expected
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $tab_stop_props);
|
||||
$this->assertEquals(4, $found);
|
||||
$this->assertEquals('15cm', $attributes['style:position']);
|
||||
$this->assertEquals('right', $attributes['style:type']);
|
||||
$this->assertEquals('dotted', $attributes['style:leader-style']);
|
||||
$this->assertEquals('.', $attributes['style:leader-text']);
|
||||
}
|
||||
}
|
106
lib/plugins/odt/_test/odt.styles.tablecellstyle.test.php
Normal file
106
lib/plugins/odt/_test/odt.styles.tablecellstyle.test.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTableCellStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_tablecellstyle_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<style:style style:name="Table1.A1" style:family="table-cell">
|
||||
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
|
||||
</style:style>';
|
||||
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$this->assertEquals($style->getFamily(), 'table-cell');
|
||||
$this->assertEquals($style->getProperty('style-name'), 'Table1.A1');
|
||||
$this->assertEquals($style->getPropertySection('style-name'), 'style');
|
||||
$this->assertEquals($style->getProperty('style-family'), 'table-cell');
|
||||
$this->assertEquals($style->getPropertySection('style-family'), 'style');
|
||||
$this->assertEquals($style->getProperty('padding'), '0.097cm');
|
||||
$this->assertEquals($style->getPropertySection('padding'), 'table-cell');
|
||||
|
||||
$this->assertEquals($style->getProperty('border-left'), '0.05pt solid #000000');
|
||||
$this->assertEquals($style->getPropertySection('border-left'), 'table-cell');
|
||||
$this->assertEquals($style->getProperty('border-right'), 'none');
|
||||
$this->assertEquals($style->getPropertySection('border-right'), 'table-cell');
|
||||
$this->assertEquals($style->getProperty('border-top'), '0.05pt solid #000000');
|
||||
$this->assertEquals($style->getPropertySection('border-top'), 'table-cell');
|
||||
$this->assertEquals($style->getProperty('border-bottom'), '0.05pt solid #000000');
|
||||
$this->assertEquals($style->getPropertySection('border-bottom'), 'table-cell');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:style style:name="Table1.A1" style:family="table-cell">
|
||||
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
|
||||
</style:style>';
|
||||
$expected = '<style:style style:name="Table1.A1" style:family="table-cell" >'."\n";
|
||||
$expected .= ' <style:table-cell-properties fo:border-top="0.05pt solid #000000" fo:border-right="none" fo:border-bottom="0.05pt solid #000000" fo:border-left="0.05pt solid #000000" fo:padding="0.097cm" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<style:style style:name="Table1.A1" style:family="table-cell">
|
||||
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setProperty('padding', '5cm');
|
||||
|
||||
$this->assertEquals($style->getProperty('padding'), '5cm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties import and conversion to string.
|
||||
*/
|
||||
public function test_import_properties_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'Table1.A1';
|
||||
$properties ['border-top'] = '0.05pt solid #000000';
|
||||
$properties ['border-right'] = 'none';
|
||||
$properties ['border-left'] = '0.05pt solid #000000';
|
||||
$properties ['border-bottom'] = '0.05pt solid #000000';
|
||||
$properties ['padding'] = '0.097cm';
|
||||
|
||||
$expected = '<style:style style:name="Table1.A1" style:family="table-cell" >'."\n";
|
||||
$expected .= ' <style:table-cell-properties fo:border-top="0.05pt solid #000000" fo:border-right="none" fo:border-left="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000" fo:padding="0.097cm" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTTableCellStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->importProperties($properties, NULL);
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
}
|
103
lib/plugins/odt/_test/odt.styles.tablecolumnstyle.test.php
Normal file
103
lib/plugins/odt/_test/odt.styles.tablecolumnstyle.test.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for Table column style.
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author LarsDW223
|
||||
* @package Tests\Styles\TableColumnStyle
|
||||
*/
|
||||
|
||||
/** Include ODTStyle */
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTableColumnStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_tablecolumnstyle_test extends DokuWikiTest {
|
||||
/**
|
||||
* Setup.
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<style:style style:name="Table1.A" style:family="table-column">
|
||||
<style:table-column-properties style:column-width="5.609cm"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$this->assertEquals($style->getFamily(), 'table-column');
|
||||
$this->assertEquals($style->getProperty('style-name'), 'Table1.A');
|
||||
$this->assertEquals($style->getPropertySection('style-name'), 'style');
|
||||
$this->assertEquals($style->getProperty('style-family'), 'table-column');
|
||||
$this->assertEquals($style->getPropertySection('style-family'), 'style');
|
||||
$this->assertEquals($style->getProperty('column-width'), '5.609cm');
|
||||
$this->assertEquals($style->getPropertySection('column-width'), 'table-column');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:style style:name="Table1.A" style:family="table-column">
|
||||
<style:table-column-properties style:column-width="5.609cm"/>
|
||||
</style:style>';
|
||||
$expected = '<style:style style:name="Table1.A" style:family="table-column" >'."\n";
|
||||
$expected .= ' <style:table-column-properties style:column-width="5.609cm" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<style:style style:name="Table1.A" style:family="table-column">
|
||||
<style:table-column-properties style:column-width="5.609cm"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setProperty('column-width', '12.345cm');
|
||||
|
||||
$this->assertEquals($style->getProperty('column-width'), '12.345cm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties import and conversion to string.
|
||||
*/
|
||||
public function test_import_properties_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'Table1.A';
|
||||
$properties ['column-width'] = '5.609cm';
|
||||
|
||||
$expected = '<style:style style:name="Table1.A" style:family="table-column" >'."\n";
|
||||
$expected .= ' <style:table-column-properties style:column-width="5.609cm" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTTableColumnStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->importProperties($properties, NULL);
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
}
|
92
lib/plugins/odt/_test/odt.styles.tablerowstyle.test.php
Normal file
92
lib/plugins/odt/_test/odt.styles.tablerowstyle.test.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTableRowStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_tablerowstyle_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<style:style style:name="Table1.2" style:family="table-row">
|
||||
<style:table-row-properties style:min-row-height="2.228cm"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$this->assertEquals($style->getFamily(), 'table-row');
|
||||
$this->assertEquals($style->getProperty('style-name'), 'Table1.2');
|
||||
$this->assertEquals($style->getPropertySection('style-name'), 'style');
|
||||
$this->assertEquals($style->getProperty('style-family'), 'table-row');
|
||||
$this->assertEquals($style->getPropertySection('style-family'), 'style');
|
||||
$this->assertEquals($style->getProperty('min-row-height'), '2.228cm');
|
||||
$this->assertEquals($style->getPropertySection('min-row-height'), 'table-row');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:style style:name="Table1.2" style:family="table-row">
|
||||
<style:table-row-properties style:min-row-height="2.228cm"/>
|
||||
</style:style>';
|
||||
$expected = '<style:style style:name="Table1.2" style:family="table-row" >'."\n";
|
||||
$expected .= ' <style:table-row-properties style:min-row-height="2.228cm" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<style:style style:name="Table1.2" style:family="table-row">
|
||||
<style:table-row-properties style:min-row-height="2.228cm"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setProperty('min-row-height', '2.228cm');
|
||||
|
||||
$this->assertEquals($style->getProperty('min-row-height'), '2.228cm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties import and conversion to string.
|
||||
*/
|
||||
public function test_import_properties_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'Table1.2';
|
||||
$properties ['min-row-height'] = '2.228cm';
|
||||
|
||||
$expected = '<style:style style:name="Table1.2" style:family="table-row" >'."\n";
|
||||
$expected .= ' <style:table-row-properties style:min-row-height="2.228cm" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTTableRowStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->importProperties($properties, NULL);
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
}
|
92
lib/plugins/odt/_test/odt.styles.tablestyle.test.php
Normal file
92
lib/plugins/odt/_test/odt.styles.tablestyle.test.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTableStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_tablestyle_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<style:style style:name="TableTest" style:family="table">
|
||||
<style:table-properties table:border-model="collapsing"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$this->assertEquals($style->getFamily(), 'table');
|
||||
$this->assertEquals($style->getProperty('style-name'), 'TableTest');
|
||||
$this->assertEquals($style->getPropertySection('style-name'), 'style');
|
||||
$this->assertEquals($style->getProperty('style-family'), 'table');
|
||||
$this->assertEquals($style->getPropertySection('style-family'), 'style');
|
||||
$this->assertEquals($style->getProperty('border-model'), 'collapsing');
|
||||
$this->assertEquals($style->getPropertySection('border-model'), 'table');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:style style:name="TableTest" style:family="table">
|
||||
<style:table-properties table:border-model="collapsing"/>
|
||||
</style:style>';
|
||||
$expected = '<style:style style:name="TableTest" style:family="table" >'."\n";
|
||||
$expected .= ' <style:table-properties table:border-model="collapsing" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<style:style style:name="TableTest" style:family="table">
|
||||
<style:table-properties table:border-model="collapsing"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setProperty('border-model', 'separating');
|
||||
|
||||
$this->assertEquals($style->getProperty('border-model'), 'separating');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties import and conversion to string.
|
||||
*/
|
||||
public function test_import_properties_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'TableTest';
|
||||
$properties ['border-model'] = 'collapsing';
|
||||
|
||||
$expected = '<style:style style:name="TableTest" style:family="table" >'."\n";
|
||||
$expected .= ' <style:table-properties table:border-model="collapsing" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTTableStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->importProperties($properties, NULL);
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
}
|
333
lib/plugins/odt/_test/odt.styles.textliststyle.test.php
Normal file
333
lib/plugins/odt/_test/odt.styles.textliststyle.test.php
Normal file
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for Text list style.
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author LarsDW223
|
||||
* @package Tests\Styles\TextListStyle
|
||||
*/
|
||||
|
||||
/** Include ODTStyle */
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTextListStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_textliststyle_test extends DokuWikiTest {
|
||||
/**
|
||||
* Setup.
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code =
|
||||
'<text:list-style style:name="Numbering_20_1" style:display-name="Numbering 1">
|
||||
<text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.499cm" fo:text-indent="-0.499cm" fo:margin-left="0.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1cm" fo:text-indent="-0.499cm" fo:margin-left="1cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.499cm" fo:text-indent="-0.499cm" fo:margin-left="1.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="4" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.499cm" fo:margin-left="2cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="5" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.499cm" fo:text-indent="-0.499cm" fo:margin-left="2.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="6" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3cm" fo:text-indent="-0.499cm" fo:margin-left="3cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="7" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5cm" fo:text-indent="-0.499cm" fo:margin-left="3.5cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="8" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.499cm" fo:margin-left="4.001cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="9" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5cm" fo:text-indent="-0.499cm" fo:margin-left="4.5cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="10" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.001cm" fo:text-indent="-0.499cm" fo:margin-left="5.001cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
$dist = $style->getPropertyFromLevel(1, 'list-tab-stop-position');
|
||||
$this->assertEquals('0.499cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(2, 'list-tab-stop-position');
|
||||
$this->assertEquals('1cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(3, 'list-tab-stop-position');
|
||||
$this->assertEquals('1.499cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(4, 'list-tab-stop-position');
|
||||
$this->assertEquals('2cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(5, 'list-tab-stop-position');
|
||||
$this->assertEquals('2.499cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(6, 'list-tab-stop-position');
|
||||
$this->assertEquals('3cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(7, 'list-tab-stop-position');
|
||||
$this->assertEquals('3.5cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(8, 'list-tab-stop-position');
|
||||
$this->assertEquals('4.001cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(9, 'list-tab-stop-position');
|
||||
$this->assertEquals('4.5cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(10, 'list-tab-stop-position');
|
||||
$this->assertEquals('5.001cm', $dist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code =
|
||||
'<text:list-style style:name="List_20_1" style:display-name="List 1">
|
||||
<text:list-level-style-bullet text:level="1" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.4cm" fo:text-indent="-0.4cm" fo:margin-left="0.4cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="2" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.801cm" fo:text-indent="-0.4cm" fo:margin-left="0.801cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="StarSymbol1"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="3" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.199cm" fo:text-indent="-0.4cm" fo:margin-left="1.199cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="4" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.6cm" fo:text-indent="-0.4cm" fo:margin-left="1.6cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="5" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.4cm" fo:margin-left="2cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="6" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.401cm" fo:text-indent="-0.4cm" fo:margin-left="2.401cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="7" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.799cm" fo:text-indent="-0.4cm" fo:margin-left="2.799cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="8" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.2cm" fo:text-indent="-0.4cm" fo:margin-left="3.2cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="9" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.6cm" fo:text-indent="-0.4cm" fo:margin-left="3.6cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
<text:list-level-style-bullet text:level="10" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.4cm" fo:margin-left="4.001cm"/>
|
||||
</style:list-level-properties>
|
||||
<style:text-properties style:font-name="OpenSymbol"/>
|
||||
</text:list-level-style-bullet>
|
||||
</text:list-style>';
|
||||
|
||||
$expected = '<text:list-style style:name="List_20_1" style:display-name="List 1" >'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="1" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.4cm" fo:text-indent="-0.4cm" fo:margin-left="0.4cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="2" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.801cm" fo:text-indent="-0.4cm" fo:margin-left="0.801cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="StarSymbol1" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="3" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.199cm" fo:text-indent="-0.4cm" fo:margin-left="1.199cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="4" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.6cm" fo:text-indent="-0.4cm" fo:margin-left="1.6cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="5" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.4cm" fo:margin-left="2cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="6" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.401cm" fo:text-indent="-0.4cm" fo:margin-left="2.401cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="7" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.799cm" fo:text-indent="-0.4cm" fo:margin-left="2.799cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="8" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.2cm" fo:text-indent="-0.4cm" fo:margin-left="3.2cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="9" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.6cm" fo:text-indent="-0.4cm" fo:margin-left="3.6cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= ' <text:list-level-style-bullet text:level="10" text:style-name="Numbering_20_Symbols" text:bullet-char="•" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" >'."\n";
|
||||
$expected .= ' <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.4cm" fo:margin-left="4.001cm" />'."\n";
|
||||
$expected .= ' </style:list-level-properties>'."\n";
|
||||
$expected .= ' <style:text-properties style:font-name="OpenSymbol" />'."\n";
|
||||
$expected .= ' </text:list-level-style-bullet>'."\n";
|
||||
$expected .= '</text:list-style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code =
|
||||
'<text:list-style style:name="Numbering_20_1" style:display-name="Numbering 1">
|
||||
<text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.499cm" fo:text-indent="-0.499cm" fo:margin-left="0.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1cm" fo:text-indent="-0.499cm" fo:margin-left="1cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.499cm" fo:text-indent="-0.499cm" fo:margin-left="1.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="4" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.499cm" fo:margin-left="2cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="5" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.499cm" fo:text-indent="-0.499cm" fo:margin-left="2.499cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="6" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3cm" fo:text-indent="-0.499cm" fo:margin-left="3cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="7" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5cm" fo:text-indent="-0.499cm" fo:margin-left="3.5cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="8" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.499cm" fo:margin-left="4.001cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="9" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5cm" fo:text-indent="-0.499cm" fo:margin-left="4.5cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
<text:list-level-style-number text:level="10" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.001cm" fo:text-indent="-0.499cm" fo:margin-left="5.001cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setPropertyForLevel(5, 'list-tab-stop-position', '999cm');
|
||||
|
||||
$dist = $style->getPropertyFromLevel(1, 'list-tab-stop-position');
|
||||
$this->assertEquals('0.499cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(2, 'list-tab-stop-position');
|
||||
$this->assertEquals('1cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(3, 'list-tab-stop-position');
|
||||
$this->assertEquals('1.499cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(4, 'list-tab-stop-position');
|
||||
$this->assertEquals('2cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(5, 'list-tab-stop-position');
|
||||
$this->assertEquals('999cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(6, 'list-tab-stop-position');
|
||||
$this->assertEquals('3cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(7, 'list-tab-stop-position');
|
||||
$this->assertEquals('3.5cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(8, 'list-tab-stop-position');
|
||||
$this->assertEquals('4.001cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(9, 'list-tab-stop-position');
|
||||
$this->assertEquals('4.5cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(10, 'list-tab-stop-position');
|
||||
$this->assertEquals('5.001cm', $dist);
|
||||
}
|
||||
}
|
219
lib/plugins/odt/_test/odt.styles.textoutlinestyle.test.php
Normal file
219
lib/plugins/odt/_test/odt.styles.textoutlinestyle.test.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTextOutlineStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_textoutlinestyle_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<text:outline-style>
|
||||
<text:outline-level-style text:level="1" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="10cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="2" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="9cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="3" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="8cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="4" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="7cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="5" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="6cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="6" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="5cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="7" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="4cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="8" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="3cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="9" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="2cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="10" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="1cm"/>
|
||||
</text:outline-level-style>
|
||||
</text:outline-style>';
|
||||
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
$dist = $style->getPropertyFromLevel(1, 'text-min-label-distance');
|
||||
$this->assertEquals('10cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(2, 'text-min-label-distance');
|
||||
$this->assertEquals('9cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(3, 'text-min-label-distance');
|
||||
$this->assertEquals('8cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(4, 'text-min-label-distance');
|
||||
$this->assertEquals('7cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(5, 'text-min-label-distance');
|
||||
$this->assertEquals('6cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(6, 'text-min-label-distance');
|
||||
$this->assertEquals('5cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(7, 'text-min-label-distance');
|
||||
$this->assertEquals('4cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(8, 'text-min-label-distance');
|
||||
$this->assertEquals('3cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(9, 'text-min-label-distance');
|
||||
$this->assertEquals('2cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(10, 'text-min-label-distance');
|
||||
$this->assertEquals('1cm', $dist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<text:outline-style>
|
||||
<text:outline-level-style text:level="1" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="10cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="2" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="9cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="3" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="8cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="4" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="7cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="5" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="6cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="6" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="5cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="7" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="4cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="8" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="3cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="9" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="2cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="10" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="1cm"/>
|
||||
</text:outline-level-style>
|
||||
</text:outline-style>';
|
||||
$expected = '<text:outline-style >'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="1" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="10cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="2" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="9cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="3" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="8cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="4" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="7cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="5" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="6cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="6" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="5cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="7" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="4cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="8" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="3cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="9" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="2cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= ' <text:outline-level-style text:level="10" style:num-format="" >'."\n";
|
||||
$expected .= ' <style:list-level-properties text:min-label-distance="1cm" />'."\n";
|
||||
$expected .= ' </text:outline-level-style>'."\n";
|
||||
$expected .= '</text:outline-style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<text:outline-style>
|
||||
<text:outline-level-style text:level="1" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="10cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="2" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="9cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="3" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="8cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="4" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="7cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="5" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="6cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="6" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="5cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="7" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="4cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="8" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="3cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="9" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="2cm"/>
|
||||
</text:outline-level-style>
|
||||
<text:outline-level-style text:level="10" style:num-format="">
|
||||
<style:list-level-properties text:min-label-distance="1cm"/>
|
||||
</text:outline-level-style>
|
||||
</text:outline-style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setPropertyForLevel(5, 'text-min-label-distance', '999cm');
|
||||
|
||||
$dist = $style->getPropertyFromLevel(1, 'text-min-label-distance');
|
||||
$this->assertEquals('10cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(2, 'text-min-label-distance');
|
||||
$this->assertEquals('9cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(3, 'text-min-label-distance');
|
||||
$this->assertEquals('8cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(4, 'text-min-label-distance');
|
||||
$this->assertEquals('7cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(5, 'text-min-label-distance');
|
||||
$this->assertEquals('999cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(6, 'text-min-label-distance');
|
||||
$this->assertEquals('5cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(7, 'text-min-label-distance');
|
||||
$this->assertEquals('4cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(8, 'text-min-label-distance');
|
||||
$this->assertEquals('3cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(9, 'text-min-label-distance');
|
||||
$this->assertEquals('2cm', $dist);
|
||||
$dist = $style->getPropertyFromLevel(10, 'text-min-label-distance');
|
||||
$this->assertEquals('1cm', $dist);
|
||||
}
|
||||
}
|
92
lib/plugins/odt/_test/odt.styles.textstyle.test.php
Normal file
92
lib/plugins/odt/_test/odt.styles.textstyle.test.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTTextStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_textstyle_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import.
|
||||
*/
|
||||
public function test_simple_odt_import() {
|
||||
$xml_code = '<style:style style:name="test" style:family="text">
|
||||
<style:text-properties fo:color="#ff0000"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$this->assertEquals($style->getFamily(), 'text');
|
||||
$this->assertEquals($style->getProperty('style-name'), 'test');
|
||||
$this->assertEquals($style->getPropertySection('style-name'), 'style');
|
||||
$this->assertEquals($style->getProperty('style-family'), 'text');
|
||||
$this->assertEquals($style->getPropertySection('style-family'), 'style');
|
||||
$this->assertEquals($style->getProperty('color'), '#ff0000');
|
||||
$this->assertEquals($style->getPropertySection('color'), 'text');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:style style:name="test" style:family="text">
|
||||
<style:text-properties fo:color="#ff0000"/>
|
||||
</style:style>';
|
||||
$expected = '<style:style style:name="test" style:family="text" >'."\n";
|
||||
$expected .= ' <style:text-properties fo:color="#ff0000" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get of a property.
|
||||
*/
|
||||
public function test_set_and_get() {
|
||||
$xml_code = '<style:style style:name="test" style:family="text">
|
||||
<style:text-properties fo:color="#ffffff"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->setProperty('color', '#000000');
|
||||
|
||||
$this->assertEquals($style->getProperty('color'), '#000000');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties import and conversion to string.
|
||||
*/
|
||||
public function test_import_properties_and_to_string() {
|
||||
$properties = array();
|
||||
$properties ['style-name'] = 'test';
|
||||
$properties ['color'] = '#ff0000';
|
||||
|
||||
$expected = '<style:style style:name="test" style:family="text" >'."\n";
|
||||
$expected .= ' <style:text-properties fo:color="#ff0000" />'."\n";
|
||||
$expected .= '</style:style>'."\n";
|
||||
|
||||
$style = new ODTTextStyle();
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style->importProperties($properties, NULL);
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($expected, $style_string);
|
||||
}
|
||||
}
|
56
lib/plugins/odt/_test/odt.styles.unknownstyle.test.php
Normal file
56
lib/plugins/odt/_test/odt.styles.unknownstyle.test.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/styles/ODTStyle.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the ODTUnknownStyle class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_unknownstyle_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string() {
|
||||
$xml_code = '<style:default-style style:family="graphic">
|
||||
<style:graphic-properties draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
|
||||
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
|
||||
<style:tab-stops/>
|
||||
</style:paragraph-properties>
|
||||
<style:text-properties style:use-window-font-color="true" fo:font-size="12pt" style:font-size-asian="12pt" style:font-size-complex="12pt"/>
|
||||
</style:default-style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($xml_code."\n", $style_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ODT XML style definition import and conversion to string.
|
||||
*/
|
||||
public function test_import_and_to_string_2() {
|
||||
$xml_code = '<style:style style:family="NothingIKnow">
|
||||
<style:graphic-properties draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
|
||||
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
|
||||
<style:tab-stops/>
|
||||
</style:paragraph-properties>
|
||||
<style:text-properties style:use-window-font-color="true" fo:font-size="12pt" style:font-size-asian="12pt" style:font-size-complex="12pt"/>
|
||||
</style:style>';
|
||||
|
||||
$style = ODTStyle::importODTStyle($xml_code);
|
||||
$this->assertNotNull($style);
|
||||
|
||||
$style_string = $style->toString();
|
||||
|
||||
$this->assertEquals($xml_code."\n", $style_string);
|
||||
}
|
||||
}
|
155
lib/plugins/odt/_test/odt.xmlutil.test.php
Normal file
155
lib/plugins/odt/_test/odt.xmlutil.test.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/XMLUtil.php';
|
||||
require_once DOKU_INC.'lib/plugins/odt/ODT/ODTDefaultStyles.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the XMLUtil class.
|
||||
*
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_xmlutil_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElement_1() {
|
||||
$xmlCode = '<a><b>Hallo</b></a>';
|
||||
|
||||
$found = XMLUtil::getElement('a', $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals($xmlCode, $found);
|
||||
$this->assertEquals(strlen($xmlCode), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElement_2() {
|
||||
$xmlCode = '<a peng><b>Hallo</b></a>';
|
||||
|
||||
$found = XMLUtil::getElement('a', $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals($xmlCode, $found);
|
||||
$this->assertEquals(strlen($xmlCode), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElement_3() {
|
||||
$xmlCode = '</peng><a peng><b>Hallo</b></a>';
|
||||
|
||||
$found = XMLUtil::getElement('a', $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals('<a peng><b>Hallo</b></a>', $found);
|
||||
$this->assertEquals(strlen($xmlCode), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElement_4() {
|
||||
$xmlCode = '</peng><a peng="5"><b>Hallo</b></a><anotherOne></anotherOne>';
|
||||
|
||||
$found = XMLUtil::getElement('a', $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals('<a peng="5"><b>Hallo</b></a>', $found);
|
||||
$this->assertEquals(strlen($xmlCode)-strlen('<anotherOne></anotherOne>'), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElement_5() {
|
||||
$xmlCode = '</peng><a peng="dsfg"/><anotherOne></anotherOne>';
|
||||
|
||||
$found = XMLUtil::getElement('a', $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals('<a peng="dsfg"/>', $found);
|
||||
$this->assertEquals(strlen($xmlCode)-strlen('<anotherOne></anotherOne>'), $end);
|
||||
$this->assertEquals(23, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElementContent()
|
||||
*/
|
||||
public function test_getElementContent_1() {
|
||||
$xmlCode = '<a><b>Hallo</b></a>';
|
||||
|
||||
$found = XMLUtil::getElementContent('a', $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals('<b>Hallo</b>', $found);
|
||||
$this->assertEquals(strlen($xmlCode), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElementContent_2() {
|
||||
$xmlCode = '</peng><a peng="dsfg"/><anotherOne></anotherOne>';
|
||||
|
||||
$found = XMLUtil::getElementContent('a', $xmlCode, $end);
|
||||
$this->assertNull($found);
|
||||
$this->assertEquals(strlen($xmlCode)-strlen('<anotherOne></anotherOne>'), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getElement()
|
||||
*/
|
||||
public function test_getElementContent_3() {
|
||||
$xmlCode = '</peng><abc peng="dsfg"></abc><anotherOne></anotherOne>';
|
||||
|
||||
$found = XMLUtil::getElementContent('abc', $xmlCode, $end);
|
||||
$this->assertNull($found);
|
||||
$this->assertEquals(strlen($xmlCode)-strlen('<anotherOne></anotherOne>'), $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getNextElement()
|
||||
*/
|
||||
public function test_getNextElement_1() {
|
||||
$xmlCode = '</peng><unknown peng="5"><b>Hallo</b></unknown><anotherOne></anotherOne>';
|
||||
|
||||
$found = XMLUtil::getNextElement($element, $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals('<unknown peng="5"><b>Hallo</b></unknown>', $found);
|
||||
$this->assertEquals(strlen($xmlCode)-strlen('<anotherOne></anotherOne>'), $end);
|
||||
$this->assertEquals('unknown', $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getNextElement()
|
||||
*/
|
||||
public function test_getNextElementContent_1() {
|
||||
$xmlCode = '</peng><unknown peng="5"><b>Hallo</b></unknown><anotherOne></anotherOne>';
|
||||
|
||||
$found = XMLUtil::getNextElementContent($element, $xmlCode, $end);
|
||||
$this->assertNotNull($found);
|
||||
$this->assertEquals('<b>Hallo</b>', $found);
|
||||
$this->assertEquals(strlen($xmlCode)-strlen('<anotherOne></anotherOne>'), $end);
|
||||
$this->assertEquals('unknown', $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function getAttributes()
|
||||
*/
|
||||
public function test_getAttributes() {
|
||||
$xmlCode = '<test attr1="1" attr2="22" attr3="333" attr4="4444" attr5="55555"></test>';
|
||||
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $xmlCode);
|
||||
|
||||
$this->assertEquals(5, $found);
|
||||
$this->assertEquals('1', $attributes['attr1']);
|
||||
$this->assertEquals('22', $attributes['attr2']);
|
||||
$this->assertEquals('333', $attributes['attr3']);
|
||||
$this->assertEquals('4444', $attributes['attr4']);
|
||||
$this->assertEquals('55555', $attributes['attr5']);
|
||||
}
|
||||
}
|
191
lib/plugins/odt/_test/renderer.formating.test.php
Normal file
191
lib/plugins/odt/_test/renderer.formating.test.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/**
|
||||
* Formatting tests.
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author LarsDW223
|
||||
* @package Tests\Renderer\Formatting
|
||||
*/
|
||||
|
||||
/** Include ODTTestUtils */
|
||||
require_once 'ODTTestUtils.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure that the text fomrating of the document is rendered correctly.
|
||||
* (bold, italic, underlined.. text)
|
||||
*
|
||||
* @group plugin_odt_renderer
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_renderer_format_test extends DokuWikiTest {
|
||||
/**
|
||||
* Setup.
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup before class.
|
||||
*
|
||||
* Copy our required test files.
|
||||
*/
|
||||
public static function setUpBeforeClass(){
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// copy test files to test directory
|
||||
TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks the rendering of bold text.
|
||||
*/
|
||||
public function test_bold_text () {
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, '**This is bold text.**');
|
||||
$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 bold text.');
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $span_attrs);
|
||||
$this->assertEquals(1, $found);
|
||||
$this->assertEquals('Strong_20_Emphasis', $attributes['text:style-name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks the rendering of italic text.
|
||||
*/
|
||||
public function test_italic_text () {
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, '//This is italic text.//');
|
||||
$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 italic text.');
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $span_attrs);
|
||||
$this->assertEquals(1, $found);
|
||||
$this->assertEquals('Emphasis', $attributes['text:style-name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks the rendering of underlined text.
|
||||
*/
|
||||
public function test_underlined_text () {
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, '__This is underlined text.__');
|
||||
$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 underlined text.');
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $span_attrs);
|
||||
$this->assertEquals(1, $found);
|
||||
$this->assertEquals('underline', $attributes['text:style-name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks the rendering of monospaced text.
|
||||
*/
|
||||
public function test_monospaced_text () {
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, "''This is monospaced text.''");
|
||||
$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 monospaced text.');
|
||||
$attributes = array();
|
||||
$found = XMLUtil::getAttributes($attributes, $span_attrs);
|
||||
$this->assertEquals(1, $found);
|
||||
$this->assertEquals('Source_20_Text', $attributes['text:style-name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']);
|
||||
}
|
||||
}
|
112
lib/plugins/odt/_test/renderer.image.test.php
Normal file
112
lib/plugins/odt/_test/renderer.image.test.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests to ensure that images are handled correctly by the renderer
|
||||
*
|
||||
* @group plugin_odt_renderer
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_renderer_image_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(){
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// Copy test media files to test wiki namespace
|
||||
ODTTestUtils::rcopyMedia('wiki', dirname(__FILE__) . '/data/media/wiki/');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if a image is included with the correct size.
|
||||
* Therefore an test image with known size is choosen (TestPicture100x50.png).
|
||||
*/
|
||||
public function test_image_size() {
|
||||
$units = new helper_plugin_odt_units ();
|
||||
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, '{{wiki:TestPicture100x50.png}}');
|
||||
$this->assertFalse($ok == false, 'Error rendering, creating, unpacking, reading ODT doc!');
|
||||
$encoded = $files['content-xml'];
|
||||
|
||||
// There should be a frame
|
||||
$start = strpos($encoded, '<draw:frame');
|
||||
$end = strpos($encoded, '</draw:frame>');
|
||||
$frame = substr($encoded, $start, $end+strlen('</draw:frame>')-$start);
|
||||
$this->assertFalse(empty($frame));
|
||||
|
||||
// Check that the width has the unit 'cm' and that it is
|
||||
// calculated according to the formula ($width/96.0)*2.54
|
||||
$result = preg_match('/svg:width="[^"]*"/', $encoded, $widths);
|
||||
$this->assertEquals($result, 1);
|
||||
|
||||
$unit = substr($widths [0], strlen('svg:width='));
|
||||
$unit = trim($unit, '"');
|
||||
$width = $units->getDigits($unit);
|
||||
$unit = $units->stripDigits($unit);
|
||||
|
||||
$this->assertEquals($unit, 'cm');
|
||||
$this->assertEquals($width, (100/96.0)*2.54);
|
||||
|
||||
// Check that the height has the unit 'cm' and that it is
|
||||
// calculated according to the formula ($height/96.0)*2.54
|
||||
$result = preg_match('/svg:height="[^"]*"/', $encoded, $heights);
|
||||
$this->assertEquals($result, 1);
|
||||
|
||||
$unit = substr($heights [0], strlen('svg:height='));
|
||||
$unit = trim($unit, '"');
|
||||
$height = $units->getDigits($unit);
|
||||
$unit = $units->stripDigits($unit);
|
||||
|
||||
$this->assertEquals($unit, 'cm');
|
||||
$this->assertEquals($height, (50/96.0)*2.54);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if a image is included with the correct size.
|
||||
* Therefore an test image with known size is choosen (TestPicture500x256.png).
|
||||
*/
|
||||
public function test_image_size_2() {
|
||||
$units = new helper_plugin_odt_units ();
|
||||
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, '{{wiki:TestPicture500x256.png}}');
|
||||
$this->assertFalse($ok == false, 'Error rendering, creating, unpacking, reading ODT doc!');
|
||||
$encoded = $files['content-xml'];
|
||||
|
||||
// There should be a frame
|
||||
$start = strpos($encoded, '<draw:frame');
|
||||
$end = strpos($encoded, '</draw:frame>');
|
||||
$frame = substr($encoded, $start, $end+strlen('</draw:frame>')-$start);
|
||||
$this->assertFalse(empty($frame));
|
||||
|
||||
// Check that the width has the unit 'cm' and that it is
|
||||
// calculated according to the formula ($width/96.0)*2.54
|
||||
$result = preg_match('/svg:width="[^"]*"/', $encoded, $widths);
|
||||
$this->assertEquals($result, 1);
|
||||
|
||||
$unit = substr($widths [0], strlen('svg:width='));
|
||||
$unit = trim($unit, '"');
|
||||
$width = $units->getDigits($unit);
|
||||
$unit = $units->stripDigits($unit);
|
||||
|
||||
$this->assertEquals($unit, 'cm');
|
||||
$this->assertEquals($width, (500/96.0)*2.54);
|
||||
|
||||
// Check that the height has the unit 'cm' and that it is
|
||||
// calculated according to the formula ($height/96.0)*2.54
|
||||
$result = preg_match('/svg:height="[^"]*"/', $encoded, $heights);
|
||||
$this->assertEquals($result, 1);
|
||||
|
||||
$unit = substr($heights [0], strlen('svg:height='));
|
||||
$unit = trim($unit, '"');
|
||||
$height = $units->getDigits($unit);
|
||||
$unit = $units->stripDigits($unit);
|
||||
|
||||
$this->assertEquals($unit, 'cm');
|
||||
$this->assertEquals($height, (256/96.0)*2.54);
|
||||
}
|
||||
}
|
178
lib/plugins/odt/_test/renderer.start.test.php
Normal file
178
lib/plugins/odt/_test/renderer.start.test.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
require_once 'ODTTestUtils.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure that the start of the document is rendered correctly.
|
||||
*
|
||||
* @group plugin_odt_renderer
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_renderer_start_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(){
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// copy test files to test directory
|
||||
TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks that the document does not include extra
|
||||
* paragraphs if the wiki page starts with simple text.
|
||||
*
|
||||
* Extra paragraphs without text content would cause the document to
|
||||
* start with an empty line(s).
|
||||
*/
|
||||
public function test_start_simple_text () {
|
||||
// Render document with one text line only.
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, 'This is the first line.');
|
||||
$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 != 'This is the first line.',
|
||||
"First paragraph does not include first line!");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks that the document does not include extra
|
||||
* paragraphs if the wiki page starts with a heading.
|
||||
*
|
||||
* Extra paragraphs without text content would cause the document to
|
||||
* start with an empty line(s).
|
||||
*/
|
||||
public function test_start_heading () {
|
||||
// Render document with one heading only.
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, '====== This is the first line ======');
|
||||
$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, $paragraph_end);
|
||||
|
||||
// Get first heading
|
||||
$heading = XMLUtil::getElementContent('text:h', $office_text, $heading_end);
|
||||
$this->assertFalse($heading == NULL, "Heading not found!");
|
||||
$found = preg_match('/This is the first line/', $heading);
|
||||
$this->assertFalse($found != 1, "Heading does not include first line!");
|
||||
|
||||
// If there is a paragraph, it should start behind the heading
|
||||
if ( $paragraph !== NULL ) {
|
||||
$this->assertFalse($paragraph_end >= $heading_end, "Paragraph before heading found!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks that the document does not include extra
|
||||
* paragraphs if the wiki page starts with a list.
|
||||
*
|
||||
* Extra paragraphs without text content would cause the document to
|
||||
* start with an empty line(s).
|
||||
*/
|
||||
public function test_start_list () {
|
||||
// Render document with one list only.
|
||||
$files = array();
|
||||
$page = " *List item 1\n";
|
||||
$page .= " *List item 2\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 list and first list paragraph
|
||||
$list = XMLUtil::getElementContent('text:list', $office_text);
|
||||
$list_paragraph = XMLUtil::getElementContent('text:p', $list);
|
||||
$this->assertFalse($list_paragraph != 'List item 1',
|
||||
"First list paragraph does not include first line!");
|
||||
$this->assertFalse($list_paragraph != $paragraph,
|
||||
"First list paragraph is not the first paragraph!");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks that the document does not include extra
|
||||
* paragraphs if the wiki page starts with a ordered list.
|
||||
*
|
||||
* Extra paragraphs without text content would cause the document to
|
||||
* start with an empty line(s).
|
||||
*/
|
||||
public function test_start_ordered_list () {
|
||||
// Render document with one list only.
|
||||
$files = array();
|
||||
$page = " -List item 1\n";
|
||||
$page .= " -List item 2\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 list and first list paragraph
|
||||
$list = XMLUtil::getElementContent('text:list', $office_text);
|
||||
$list_paragraph = XMLUtil::getElementContent('text:p', $list);
|
||||
$this->assertFalse($list_paragraph != 'List item 1',
|
||||
"First list paragraph does not include first line!");
|
||||
$this->assertFalse($list_paragraph != $paragraph,
|
||||
"First list paragraph is not the first paragraph!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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!");
|
||||
}
|
||||
}
|
65
lib/plugins/odt/_test/renderer.table.test.php
Normal file
65
lib/plugins/odt/_test/renderer.table.test.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests to ensure that tables are handled correctly by the renderer
|
||||
*
|
||||
* @group plugin_odt_renderer
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_renderer_table_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(){
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// Copy test media files to test wiki namespace
|
||||
// So far not required for table tests
|
||||
//ODTTestUtils::rcopyMedia('wiki', dirname(__FILE__) . '/data/media/wiki/');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if a image is included with the correct size.
|
||||
* Therefore an test image with known size is choosen (TestPicture100x50.png).
|
||||
*/
|
||||
public function test_tables() {
|
||||
$testpage = '
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
^ Spalte 1 ^ Lange Spalte 2 ^ Spalte 3 ^
|
||||
| Test Test Test | | |
|
||||
| | Test Test Test | Test Test Test |
|
||||
|
||||
^ Spalte 1 ^ Lange Spalte 2 ^ Spalte 3 ^
|
||||
| Test Test Test | | |
|
||||
| | Test Test Test | Test Test Test |
|
||||
|
||||
^ Heading 1 ^ Heading 2 ^ Heading 3 ^
|
||||
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
|
||||
| Row 2 Col 1 | some colspan (note the double pipe) ||
|
||||
| Row 3 Col 1 | Row 3 Col 2 | Row 3 Col 3 |
|
||||
|
||||
| ^ Heading 1 ^ Heading 2 ^
|
||||
^ Heading 3 | Row 1 Col 2 | Row 1 Col 3 |
|
||||
^ Heading 4 | no colspan this time | |
|
||||
^ Heading 5 | Row 2 Col 2 | Row 2 Col 3 |
|
||||
|
||||
^ Heading 1 ^ Heading 2 ^ Heading 3 ^
|
||||
| Row 1 Col 1 | this cell spans vertically | Row 1 Col 3 |
|
||||
| Row 2 Col 1 | ::: | Row 2 Col 3 |
|
||||
| Row 3 Col 1 | ::: | Row 2 Col 3 |
|
||||
|
||||
^ Table with alignment ^^^
|
||||
| right| center |left |
|
||||
|left | right| center |
|
||||
| xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx |
|
||||
';
|
||||
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, $testpage);
|
||||
$this->assertFalse($ok == false, 'Error rendering, creating, unpacking, reading ODT doc!');
|
||||
}
|
||||
}
|
80
lib/plugins/odt/_test/renderer.toc.test.php
Normal file
80
lib/plugins/odt/_test/renderer.toc.test.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests to ensure that table of contents are handled correctly by the renderer
|
||||
*
|
||||
* @group plugin_odt_renderer
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_renderer_toc_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(){
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// Copy test media files to test wiki namespace
|
||||
// So far not required for table tests
|
||||
//ODTTestUtils::rcopyMedia('wiki', dirname(__FILE__) . '/data/media/wiki/');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if a toc using all options can be rendered
|
||||
* without crashing.
|
||||
*/
|
||||
public function test_toc() {
|
||||
$testpage = '
|
||||
{{odt>toc:pagebreak=true;maxlevel=2;title=My ToC;leader_sign=-;indents=0,2,2,2,2,2,2,2,2,2,2;styleH="color: red;";
|
||||
styleL1="color: chartreuse;";styleL2="color: coral;";styleL3="color: royalblue;";}}
|
||||
|
||||
====== Chapter 1 Headline ======
|
||||
|
||||
{{odt>chapter-index:pagebreak=false;}}
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
===== Chapter 1.1 Headline =====
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
==== Chapter 1.1.1 Headline ====
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
==== Chapter 1.1.2 Headline ====
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
==== Chapter 1.1.3 Headline ====
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
===== Chapter 1.2 Headline =====
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
===== Chapter 1.3 Headline =====
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
====== Chapter 2 Headline ======
|
||||
|
||||
{{odt>chapter-index:pagebreak=false;}}
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
|
||||
====== Chapter 3 Headline ======
|
||||
|
||||
{{odt>chapter-index:pagebreak=false;}}
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
';
|
||||
|
||||
$files = array();
|
||||
$ok = ODTTestUtils::getRenderedODTDocument($files, $testpage);
|
||||
$this->assertFalse($ok == false, 'Error rendering, creating, unpacking, reading ODT doc!');
|
||||
}
|
||||
}
|
98
lib/plugins/odt/_test/units.test.php
Normal file
98
lib/plugins/odt/_test/units.test.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
require_once DOKU_INC.'lib/plugins/odt/helper/units.php';
|
||||
|
||||
/**
|
||||
* Tests to ensure functionality of the units helper class.
|
||||
*
|
||||
* @group plugin_odt_units
|
||||
* @group plugin_odt
|
||||
* @group plugins
|
||||
*/
|
||||
class plugin_odt_units_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
$this->pluginsEnabled[] = 'odt';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that stripDigits() strips all digits from the left correctly.
|
||||
*/
|
||||
public function test_stripDigits() {
|
||||
$units = new helper_plugin_odt_units ();
|
||||
|
||||
$this->assertEquals($units->stripDigits('1cm'), 'cm');
|
||||
$this->assertEquals($units->stripDigits('12mm'), 'mm');
|
||||
$this->assertEquals($units->stripDigits('123in'), 'in');
|
||||
$this->assertEquals($units->stripDigits('1234pt'), 'pt');
|
||||
$this->assertEquals($units->stripDigits('12345pc'), 'pc');
|
||||
$this->assertEquals($units->stripDigits('123456px'), 'px');
|
||||
$this->assertEquals($units->stripDigits('1234567em'), 'em');
|
||||
$this->assertEquals($units->stripDigits('9m'), 'm');
|
||||
$this->assertEquals($units->stripDigits('9km'), 'km');
|
||||
$this->assertEquals($units->stripDigits('9mi'), 'mi');
|
||||
$this->assertEquals($units->stripDigits('9ft'), 'ft');
|
||||
$this->assertEquals($units->stripDigits('9ft23'), 'ft23');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that hasValidXSLUnit() recongizes XSL units correctly.
|
||||
*/
|
||||
public function test_hasValidXSLUnit() {
|
||||
$units = new helper_plugin_odt_units ();
|
||||
|
||||
$this->assertEquals($units->hasValidXSLUnit('1cm'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('12mm'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('123in'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('1234pt'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('12345pc'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('123456px'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('1234567em'), true);
|
||||
$this->assertEquals($units->hasValidXSLUnit('9m'), false);
|
||||
$this->assertEquals($units->hasValidXSLUnit('9km'), false);
|
||||
$this->assertEquals($units->hasValidXSLUnit('9mi'), false);
|
||||
$this->assertEquals($units->hasValidXSLUnit('9ft'), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that pixelToPoints function convert to points correctly.
|
||||
*/
|
||||
public function test_pixelToPoints() {
|
||||
$units = new helper_plugin_odt_units ();
|
||||
|
||||
// First with default values.
|
||||
$this->assertEquals($units->pixelToPointsX('1px'), '0.8pt');
|
||||
$this->assertEquals($units->pixelToPointsY('1px'), '1pt');
|
||||
|
||||
// Then with set values.
|
||||
$units->setTwipsPerPixelX(32);
|
||||
$units->setTwipsPerPixelY(40);
|
||||
|
||||
$this->assertEquals($units->getTwipsPerPixelX(), 32);
|
||||
$this->assertEquals($units->getTwipsPerPixelY(), 40);
|
||||
$this->assertEquals($units->pixelToPointsX('1px'), '1.6pt');
|
||||
$this->assertEquals($units->pixelToPointsY('1px'), '2pt');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that conversion to points works correctly.
|
||||
*/
|
||||
public function test_toPoints() {
|
||||
$units = new helper_plugin_odt_units ();
|
||||
|
||||
// Set base values.
|
||||
$units->setTwipsPerPixelX(16);
|
||||
$units->setTwipsPerPixelY(20);
|
||||
$units->setPixelPerEm(14);
|
||||
|
||||
$this->assertEquals($units->getPixelPerEm(), 14);
|
||||
|
||||
$this->assertEquals($units->toPoints('1cm'), '28.35pt');
|
||||
$this->assertEquals($units->toPoints('1mm'), '2.83pt');
|
||||
$this->assertEquals($units->toPoints('1in'), '0.09pt');
|
||||
$this->assertEquals($units->toPoints('1pc'), '12pt');
|
||||
$this->assertEquals($units->toPoints('1px', 'x'), '0.8pt');
|
||||
$this->assertEquals($units->toPoints('1px', 'y'), '1pt');
|
||||
$this->assertEquals($units->toPoints('1em'), '14pt');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user