From 1eeb87d74f0d95e9b45b77fe7f7a8b6e96304e77 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 27 Feb 2024 15:54:14 +0100 Subject: [PATCH] adjust tests This could really use some more tests but this has to suffice for now. --- Output.php | 2 +- Path.php | 12 +- _test/PathTest.php | 113 +++++++++++ _test/SyntaxTest.php | 195 +++++++++++++++++++ _test/filelist.test.php | 407 ---------------------------------------- syntax.php | 2 +- 6 files changed, 321 insertions(+), 410 deletions(-) create mode 100644 _test/PathTest.php create mode 100644 _test/SyntaxTest.php delete mode 100644 _test/filelist.test.php diff --git a/Output.php b/Output.php index be7b7ae..36d3174 100644 --- a/Output.php +++ b/Output.php @@ -210,7 +210,7 @@ class Output $link['title'] = $renderer->_xmlEntities($link['url']); if ($conf['relnofollow']) $link['more'] .= ' rel="nofollow"'; [$ext,] = mimetype(basename($item['local'])); - $link['class'] .= ' mediafile mf_' . $ext; + $link['class'] = 'media mediafile mf_' . $ext; $renderer->doc .= $renderer->_formatLink($link); } diff --git a/Path.php b/Path.php index 479c8a2..01c85a3 100644 --- a/Path.php +++ b/Path.php @@ -14,6 +14,16 @@ class Path $this->paths = $this->parsePathConfig($pathConfig); } + /** + * Access the parsed paths + * + * @return array + */ + public function getPaths() + { + return $this->paths; + } + /** * Parse the path configuration into an internal array * @@ -133,7 +143,7 @@ class Path for ($i = 0; $i < $counter; $i++) { if ('.' == $path[$i]) continue; if ('' === $path[$i] && $i > 0) continue; - if ('..' == $path[$i] && '..' != $output[count($output) - 1]) { + if ('..' == $path[$i] && '..' != ($output[count($output) - 1] ?? '')) { array_pop($output); continue; } diff --git a/_test/PathTest.php b/_test/PathTest.php new file mode 100644 index 0000000..c020094 --- /dev/null +++ b/_test/PathTest.php @@ -0,0 +1,113 @@ +path = new Path( + << alias + W> webfoo +EOT + ); + } + + /** + * Test the configuration parsing for paths and aliases + */ + public function testGetPaths() + { + $expect = [ + 'C:/xampp/htdocs/wiki/' => [ + 'root' => 'C:/xampp/htdocs/wiki/', + 'web' => '/lib/plugins/filelist/file.php?root=C%3A%2Fxampp%2Fhtdocs%2Fwiki%2F&file=', + ], + '\\\\server/share/path/' => [ + 'root' => '\\\\server/share/path/', + 'web' => '/lib/plugins/filelist/file.php?root=%5C%5Cserver%2Fshare%2Fpath%2F&file=', + ], + '/linux/file/path/' => [ + 'root' => '/linux/file/path/', + 'web' => '/lib/plugins/filelist/file.php?root=%2Flinux%2Ffile%2Fpath%2F&file=', + ], + '/linux/another/path/' => [ + 'root' => '/linux/another/path/', + 'alias' => 'alias/', + 'web' => 'webfoo', + ], + 'alias/' => [ + 'root' => '/linux/another/path/', + 'alias' => 'alias/', + 'web' => 'webfoo', + ], + ]; + + $this->assertEquals($expect, $this->path->getPaths()); + } + + /** + * Data provider for testGetPathInfoSuccess + */ + public function providePathInfoSuccess() + { + return [ + ['/linux/another/path', '/linux/another/path/'], + ['/linux/another/path/foo', '/linux/another/path/foo/'], + ['alias', '/linux/another/path/'], + ['alias/foo', '/linux/another/path/foo/'], + ['C:\\xampp\\htdocs\\wiki', 'C:/xampp/htdocs/wiki/'], + ['C:\\xampp\\htdocs\\wiki\\foo', 'C:/xampp/htdocs/wiki/foo/'], + ['\\\\server\\share\\path\\', '\\\\server/share/path/'], + ['\\\\server\\share\\path\\foo', '\\\\server/share/path/foo/'], + ]; + } + + /** + * @dataProvider providePathInfoSuccess + */ + public function testGetPathInfoSuccess($path, $expect) + { + $pathInfo = $this->path->getPathInfo($path); + $this->assertEquals($expect, $pathInfo['path']); + } + + public function providePathInfoFailure() + { + return [ + ['/linux/file/path/../../../etc/'], + ['W:\\xampp\\htdocs\\wiki\\foo\\bar'], + ['/'], + ['./'], + ['../'], + ]; + } + + /** + * @dataProvider providePathInfoFailure + */ + public function testGetPathInfoFailure($path) + { + $this->expectExceptionMessageMatches('/Path not allowed/'); + $this->path->getPathInfo($path); + } +} diff --git a/_test/SyntaxTest.php b/_test/SyntaxTest.php new file mode 100644 index 0000000..b19e23a --- /dev/null +++ b/_test/SyntaxTest.php @@ -0,0 +1,195 @@ +pluginsEnabled[] = 'filelist'; + parent::setUp(); + + // Setup config so that access to the TMP directory will be allowed + $conf ['plugin']['filelist']['paths'] = TMP_DIR . '/filelistdata/' . "\n" . 'W> http://localhost/'; + + } + + public static function setUpBeforeClass(): void + { + parent::setUpBeforeClass(); + + // copy test files to test directory + \TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/filelistdata'); + } + + /** + * Run a list of checks on the given document + * + * @param Document $doc + * @param array $structure Array of selectors and expected count or content + * @return void + */ + protected function structureCheck(Document $doc, $structure) + { + foreach ($structure as $selector => $expected) { + if (is_numeric($expected)) { + $this->assertEquals( + $expected, + $doc->find($selector)->count(), + 'Selector ' . $selector . ' not found' + ); + } else { + $this->assertStringContainsString( + $expected, + $doc->find($selector)->text(), + 'Selector ' . $selector . ' not found' + ); + }; + } + } + + + /** + * This function checks that all files are listed in not recursive mode. + */ + public function test_not_recursive() + { + global $conf; + + // Render filelist + $instructions = p_get_instructions('{{filelist>' . TMP_DIR . '/filelistdata/*&style=list&direct=1}}'); + $xhtml = p_render('xhtml', $instructions, $info); + + // We should find: + // - example.txt + // - exampleimage.png + $result = strpos($xhtml, 'example.txt'); + $this->assertFalse($result === false, '"example.txt" not listed'); + $result = strpos($xhtml, 'exampleimage.png'); + $this->assertFalse($result === false, '"exampleimage.png" not listed'); + } + + /** + * This function checks that all files are listed in recursive mode. + */ + public function test_recursive() + { + // Render filelist + $instructions = p_get_instructions('{{filelist>' . TMP_DIR . '/filelistdata/*&style=list&direct=1&recursive=1}}'); + $xhtml = p_render('xhtml', $instructions, $info); + + // We should find: + // - exampledir + // - example2.txt + // - example.txt + // - exampleimage.png + $result = strpos($xhtml, 'exampledir'); + $this->assertFalse($result === false, '"exampledir" not listed'); + $result = strpos($xhtml, 'example2.txt'); + $this->assertFalse($result === false, '"example2.txt" not listed'); + $result = strpos($xhtml, 'example.txt'); + $this->assertFalse($result === false, '"example.txt" not listed'); + $result = strpos($xhtml, 'exampleimage.png'); + $this->assertFalse($result === false, '"exampleimage.png" not listed'); + } + + /** + * This function checks that the unordered list mode + * generates the expected XHTML structure. + */ + public function testUnorderedList() + { + // Render filelist + $instructions = p_get_instructions('{{filelist>' . TMP_DIR . '/filelistdata/*&style=list&direct=1&recursive=1}}'); + $xhtml = p_render('xhtml', $instructions, $info); + + $doc = new Document(); + $doc->html($xhtml); + + $structure = [ + 'div.filelist-plugin' => 1, + 'div.filelist-plugin > ul' => 1, + 'div.filelist-plugin > ul > li' => 3, + 'div.filelist-plugin > ul > li:nth-child(1)' => 1, + 'div.filelist-plugin > ul > li:nth-child(1) a' => 'example.txt', + 'div.filelist-plugin > ul > li:nth-child(2) ul' => 1, + 'div.filelist-plugin > ul > li:nth-child(2) ul > li' => 1, + 'div.filelist-plugin > ul > li:nth-child(2) ul > li a' => 'example2.txt', + ]; + + $this->structureCheck($doc, $structure); + } + + /** + * This function checks that the ordered list mode + * generates the expected XHTML structure. + */ + public function testOrderedList() + { + // Render filelist + $instructions = p_get_instructions('{{filelist>' . TMP_DIR . '/filelistdata/*&style=olist&direct=1&recursive=1}}'); + $xhtml = p_render('xhtml', $instructions, $info); + + $doc = new Document(); + $doc->html($xhtml); + + $structure = [ + 'div.filelist-plugin' => 1, + 'div.filelist-plugin > ol' => 1, + 'div.filelist-plugin > ol > li' => 3, + 'div.filelist-plugin > ol > li:nth-child(1)' => 1, + 'div.filelist-plugin > ol > li:nth-child(1) a' => 'example.txt', + 'div.filelist-plugin > ol > li:nth-child(2) ol' => 1, + 'div.filelist-plugin > ol > li:nth-child(2) ol > li' => 1, + 'div.filelist-plugin > ol > li:nth-child(2) ol > li a' => 'example2.txt', + ]; + + $this->structureCheck($doc, $structure); + } + + /** + * This function checks that the table mode + * generates the expected XHTML structure. + */ + public function test_table() + { + global $conf; + + // Render filelist + $instructions = p_get_instructions('{{filelist>' . TMP_DIR . '/filelistdata/*&style=table&direct=1&recursive=1}}'); + $xhtml = p_render('xhtml', $instructions, $info); + + $doc = new Document(); + $doc->html($xhtml); + + $structure = [ + 'div.filelist-plugin' => 1, + 'div.filelist-plugin table' => 1, + 'div.filelist-plugin table > tbody > tr' => 3, + 'div.filelist-plugin table > tbody > tr:nth-child(1) a' => 'example.txt', + 'div.filelist-plugin table > tbody > tr:nth-child(2) a' => 'exampledir/example2.txt', + 'div.filelist-plugin table > tbody > tr:nth-child(3) a' => 'exampleimage.png', + ]; + + $this->structureCheck($doc, $structure); + } +} diff --git a/_test/filelist.test.php b/_test/filelist.test.php deleted file mode 100644 index 3d6bea9..0000000 --- a/_test/filelist.test.php +++ /dev/null @@ -1,407 +0,0 @@ -pluginsEnabled[] = 'filelist'; - parent::setUp(); - - // Setup config so that access to the TMP directory will be allowed - $conf ['plugin']['filelist']['allowed_absolute_paths'] = TMP_DIR.'/filelistdata/'; - $conf ['plugin']['filelist']['web_paths'] = 'http://localhost/'; - } - - public static function setUpBeforeClass(){ - parent::setUpBeforeClass(); - - // copy test files to test directory - TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/filelistdata'); - } - - /** - * This function checks that all files are listed in not recursive mode. - */ - public function test_not_recursive () { - global $conf; - - // Render filelist - $instructions = p_get_instructions('{{filelist>'.TMP_DIR.'/filelistdata/*&style=list&direct=1}}'); - $xhtml = p_render('xhtml', $instructions, $info); - - // We should find: - // - example.txt - // - exampleimage.png - $result = strpos ($xhtml, 'example.txt'); - $this->assertFalse($result===false, '"example.txt" not listed'); - $result = strpos ($xhtml, 'exampleimage.png'); - $this->assertFalse($result===false, '"exampleimage.png" not listed'); - } - - /** - * This function checks that all files are listed in recursive mode. - */ - public function test_recursive () { - global $conf; - - // Render filelist - $instructions = p_get_instructions('{{filelist>'.TMP_DIR.'/filelistdata/*&style=list&direct=1&recursive=1}}'); - $xhtml = p_render('xhtml', $instructions, $info); - - // We should find: - // - exampledir - // - example2.txt - // - example.txt - // - exampleimage.png - $result = strpos ($xhtml, 'exampledir'); - $this->assertFalse($result===false, '"exampledir" not listed'); - $result = strpos ($xhtml, 'example2.txt'); - $this->assertFalse($result===false, '"example2.txt" not listed'); - $result = strpos ($xhtml, 'example.txt'); - $this->assertFalse($result===false, '"example.txt" not listed'); - $result = strpos ($xhtml, 'exampleimage.png'); - $this->assertFalse($result===false, '"exampleimage.png" not listed'); - } - - /** - * This function checks that the unordered list mode - * generates the expected XHTML structure. - */ - public function test_list () { - global $conf; - - // Render filelist - $instructions = p_get_instructions('{{filelist>'.TMP_DIR.'/filelistdata/*&style=list&direct=1&recursive=1}}'); - $xhtml = p_render('xhtml', $instructions, $info); - - $doc = new DOMDocument(); - $doc->loadHTML($xhtml); - - $first = $doc->documentElement; - $this->assertEquals('html', $first->tagName); - - $children = $first->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('body', $children[0]->nodeName); - - // We should have 'div' first - $children = $children[0]->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('div', $children[0]->nodeName); - - // It should have the childs text, 'ol' - $children = $children[0]->childNodes; - $this->assertTrue($children->length==2); - $this->assertEquals('#text', $children[0]->nodeName); - $this->assertEquals('ul', $children[1]->nodeName); - - // The 'ol' element should have 3 'li' childs - $children = $children[1]->childNodes; - $this->assertTrue($children->length==6); - $this->assertEquals('li', $children[0]->nodeName); - $this->assertEquals('#text', $children[1]->nodeName); - $this->assertEquals('li', $children[2]->nodeName); - $this->assertEquals('#text', $children[3]->nodeName); - $this->assertEquals('li', $children[4]->nodeName); - $this->assertEquals('#text', $children[5]->nodeName); - - // First child of first 'li' should be the link to 'example.txt' - $node = $children[0]; - $node_childs = $node->childNodes; - $this->assertEquals('level1', $node->getAttribute('class')); - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example.txt', $node_childs[0]->nodeValue); - - // First child of second 'li' is directory 'exampledir' and another 'ol' - $node = $children[2]; - $node_childs = $node->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('#text', $node_childs[0]->nodeName); - $this->assertEquals('exampledir', $node_childs[0]->nodeValue); - $this->assertEquals('ul', $node_childs[1]->nodeName); - - // That 'ol' should have one 'li' with 'class=level2' - $node_childs = $node_childs[1]->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('li', $node_childs[0]->nodeName); - $this->assertEquals('level2', $node_childs[0]->getAttribute('class')); - $this->assertEquals('#text', $node_childs[1]->nodeName); - - // The link of that 'li' should reference 'example2.txt' - $node_childs = $node_childs[0]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example2.txt', $node_childs[0]->nodeValue); - - // First child of third 'li' should be the link to 'exampleimage.png' - $node = $children[4]; - $node_childs = $node->childNodes; - $this->assertEquals('level1', $node->getAttribute('class')); - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('exampleimage.png', $node_childs[0]->nodeValue); - } - - /** - * This function checks that the ordered list mode - * generates the expected XHTML structure. - */ - public function test_olist () { - global $conf; - - // Render filelist - $instructions = p_get_instructions('{{filelist>'.TMP_DIR.'/filelistdata/*&style=olist&direct=1&recursive=1}}'); - $xhtml = p_render('xhtml', $instructions, $info); - - $doc = new DOMDocument(); - $doc->loadHTML($xhtml); - - $first = $doc->documentElement; - $this->assertEquals('html', $first->tagName); - - $children = $first->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('body', $children[0]->nodeName); - - // We should have 'div' first - $children = $children[0]->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('div', $children[0]->nodeName); - - // It should have the childs text, 'ol' - $children = $children[0]->childNodes; - $this->assertTrue($children->length==2); - $this->assertEquals('#text', $children[0]->nodeName); - $this->assertEquals('ol', $children[1]->nodeName); - - // The 'ol' element should have 3 'li' childs - $children = $children[1]->childNodes; - $this->assertTrue($children->length==6); - $this->assertEquals('li', $children[0]->nodeName); - $this->assertEquals('#text', $children[1]->nodeName); - $this->assertEquals('li', $children[2]->nodeName); - $this->assertEquals('#text', $children[3]->nodeName); - $this->assertEquals('li', $children[4]->nodeName); - $this->assertEquals('#text', $children[5]->nodeName); - - // First child of first 'li' should be the link to 'example.txt' - $node = $children[0]; - $node_childs = $node->childNodes; - $this->assertEquals('level1', $node->getAttribute('class')); - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example.txt', $node_childs[0]->nodeValue); - - // First child of second 'li' is directory 'exampledir' and another 'ol' - $node = $children[2]; - $node_childs = $node->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('#text', $node_childs[0]->nodeName); - $this->assertEquals('exampledir', $node_childs[0]->nodeValue); - $this->assertEquals('ol', $node_childs[1]->nodeName); - - // That 'ol' should have one 'li' with 'class=level2' - $node_childs = $node_childs[1]->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('li', $node_childs[0]->nodeName); - $this->assertEquals('level2', $node_childs[0]->getAttribute('class')); - $this->assertEquals('#text', $node_childs[1]->nodeName); - - // The link of that 'li' should reference 'example2.txt' - $node_childs = $node_childs[0]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example2.txt', $node_childs[0]->nodeValue); - - // First child of third 'li' should be the link to 'exampleimage.png' - $node = $children[4]; - $node_childs = $node->childNodes; - $this->assertEquals('level1', $node->getAttribute('class')); - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('exampleimage.png', $node_childs[0]->nodeValue); - } - - /** - * This function checks that the page mode - * generates the expected XHTML structure. - */ - public function test_page () { - global $conf; - - // Render filelist - $instructions = p_get_instructions('{{filelist>'.TMP_DIR.'/filelistdata/*&style=page&direct=1&recursive=1}}'); - $xhtml = p_render('xhtml', $instructions, $info); - - $doc = new DOMDocument(); - $doc->loadHTML($xhtml); - - $first = $doc->documentElement; - $this->assertEquals('html', $first->tagName); - - $children = $first->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('body', $children[0]->nodeName); - - // We should have a 'ul', 'h1', '#test' and 'div' node - $children = $children[0]->childNodes; - $this->assertTrue($children->length==4); - $this->assertEquals('ul', $children[0]->nodeName); - $this->assertEquals('h1', $children[1]->nodeName); - $this->assertEquals('#text', $children[2]->nodeName); - $this->assertEquals('div', $children[3]->nodeName); - - // 'ul' should have the childs 'li', text, 'li', text - //$children = $children[0]->childNodes; - $node_childs = $children[0]->childNodes; - $this->assertTrue($children->length==4); - $this->assertEquals('li', $node_childs[0]->nodeName); - $this->assertEquals('#text', $node_childs[1]->nodeName); - $this->assertEquals('li', $node_childs[2]->nodeName); - $this->assertEquals('#text', $node_childs[3]->nodeName); - - // Check first 'li' contents - $node = $node_childs[0]; - $node_childs = $node->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example.txt', $node_childs[0]->nodeValue); - - // Check second 'li' contents - $node = $children[0]->childNodes; - $node_childs = $node[2]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('exampleimage.png', $node_childs[0]->nodeValue); - - // Check 'h1' contents - $node = $children[1]; - $this->assertEquals('h1', $node->nodeName); - $this->assertEquals('exampledir', $node->nodeValue); - - // Check 'div' contents - $node = $children[3]; - $this->assertEquals('div', $node->nodeName); - $this->assertEquals('level1', $node->getAttribute('class')); - - // Check 'div' childs - $node_childs = $node->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('#text', $node_childs[0]->nodeName); - $this->assertEquals('ul', $node_childs[1]->nodeName); - - // Check 'ul' childs, we should have 'li' - $node_childs = $node_childs[1]->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('li', $node_childs[0]->nodeName); - $this->assertEquals('#text', $node_childs[1]->nodeName); - - // The 'li' should have a 'a' - $node_childs = $node_childs[0]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example2.txt', $node_childs[0]->nodeValue); - } - - /** - * This function checks that the table mode - * generates the expected XHTML structure. - */ - public function test_table () { - global $conf; - - // Render filelist - $instructions = p_get_instructions('{{filelist>'.TMP_DIR.'/filelistdata/*&style=table&direct=1&recursive=1}}'); - $xhtml = p_render('xhtml', $instructions, $info); - - $doc = new DOMDocument(); - $doc->loadHTML($xhtml); - - $first = $doc->documentElement; - $this->assertEquals('html', $first->tagName); - - $children = $first->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('body', $children[0]->nodeName); - - // We should have a 'div' node - $children = $children[0]->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('div', $children[0]->nodeName); - $this->assertEquals('filelist-plugin', $children[0]->getAttribute('class')); - - // Check 'div' childs - $children = $children[0]->childNodes; - $this->assertTrue($children->length==3); - $this->assertEquals('#text', $children[0]->nodeName); - $this->assertEquals('div', $children[1]->nodeName); - $this->assertEquals('table sectionedit1', $children[1]->getAttribute('class')); - $this->assertEquals('#text', $children[2]->nodeName); - - // Check inner 'div' content - $children = $children[1]->childNodes; - $this->assertTrue($children->length==1); - $this->assertEquals('table', $children[0]->nodeName); - - // Check inner 'table' content - $children = $children[0]->childNodes; - $this->assertTrue($children->length==3); - $this->assertEquals('tr', $children[0]->nodeName); - $this->assertEquals('tr', $children[1]->nodeName); - $this->assertEquals('tr', $children[2]->nodeName); - - // Check table row 1 - $node_childs = $children[0]->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('td', $node_childs[0]->nodeName); - $this->assertEquals('#text', $node_childs[1]->nodeName); - - // Check table row 1/cell 1 content - $node_childs = $node_childs[0]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('example.txt', $node_childs[0]->nodeValue); - - // Check table row 2 - $node_childs = $children[1]->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('td', $node_childs[0]->nodeName); - $this->assertEquals('#text', $node_childs[1]->nodeName); - - // Check table row 2/cell 1 content - $node_childs = $node_childs[0]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('exampledir/example2.txt', $node_childs[0]->nodeValue); - - // Check table row 3 - $node_childs = $children[2]->childNodes; - $this->assertTrue($node_childs->length==2); - $this->assertEquals('td', $node_childs[0]->nodeName); - $this->assertEquals('#text', $node_childs[1]->nodeName); - - // Check table row 3/cell 1 content - $node_childs = $node_childs[0]->childNodes; - $this->assertTrue($node_childs->length==1); - $this->assertEquals('a', $node_childs[0]->nodeName); - $this->assertEquals('exampleimage.png', $node_childs[0]->nodeValue); - - /*print_r ($node_childs->children[1]); - foreach ($node_childs as $node) { - print ("\nTEST:".$node->nodeName." : ".$node->nodeValue."\n"); - }*/ - } -} diff --git a/syntax.php b/syntax.php index 4138dcf..efd95da 100644 --- a/syntax.php +++ b/syntax.php @@ -80,7 +80,7 @@ class syntax_plugin_filelist extends SyntaxPlugin 'ftp' => 0 ]; foreach ($flags as $flag) { - [$name, $value] = explode('=', $flag); + [$name, $value] = sexplode('=', $flag, 2, ''); $params[trim($name)] = trim(trim($value), '"'); // quotes can be use to keep whitespace }