From b87a54f55cd6659b03e963fe6df11ffc37c3da85 Mon Sep 17 00:00:00 2001 From: haszi Date: Fri, 23 Feb 2024 23:03:54 +0100 Subject: [PATCH 1/6] Add Format as an optional constructor dependency to TestRender Add Format as an optional constructor dependency to TestRender. Check format's methods conditionally. Refactor tests to inject formats. --- tests/TestRender.php | 50 ++++++++++++---------- tests/php/bug49101-1.phpt | 6 +-- tests/php/bug49101-2.phpt | 6 +-- tests/php/bug49102-1.phpt | 6 +-- tests/php/bug_doc-en_GH-3179.phpt | 4 +- tests/php/constant_links_001.phpt | 4 +- tests/php/faq001.phpt | 4 +- tests/php/type_rendering_001.phpt | 4 +- tests/php/type_rendering_002.phpt | 4 +- tests/php/type_rendering_003.phpt | 4 +- tests/xhtml/001.phpt | 4 +- tests/xhtml/002.phpt | 4 +- tests/xhtml/003.phpt | 4 +- tests/xhtml/simplelist_001.phpt | 4 +- tests/xhtml/whitespace_formatting_001.phpt | 4 +- 15 files changed, 59 insertions(+), 53 deletions(-) diff --git a/tests/TestRender.php b/tests/TestRender.php index 6c74f8dc..057f8d1b 100644 --- a/tests/TestRender.php +++ b/tests/TestRender.php @@ -2,10 +2,10 @@ namespace phpdotnet\phd; class TestRender { - protected $format; + protected ?Format $format = null; public function __construct( - string $formatclass, + ?Format $format, array $opts, ?array $extra = [], ?array $indices = [] @@ -17,29 +17,32 @@ public function __construct( if (count($extra) != 0) { Config::init($extra); } - $classname = __NAMESPACE__ . "\\" . $formatclass; - $this->format = new $classname(); - - foreach ($indices as $index) { - $this->format->SQLiteIndex( - null, // $context, - null, // $index, - $index["docbook_id"] ?? "", // $id, - $index["filename"] ?? "", // $filename, - $index["parent_id"] ?? "", // $parent, - $index["sdesc"] ?? "", // $sdesc, - $index["ldesc"] ?? "", // $ldesc, - $index["element"] ?? "", // $element, - $index["previous"] ?? "", // $previous, - $index["next"] ?? "", // $next, - $index["chunk"] ?? 0, // $chunk - ); + + if ($format !== null) { + $this->format = $format; + + foreach ($indices as $index) { + $this->format->SQLiteIndex( + null, // $context, + null, // $index, + $index["docbook_id"] ?? "", // $id, + $index["filename"] ?? "", // $filename, + $index["parent_id"] ?? "", // $parent, + $index["sdesc"] ?? "", // $sdesc, + $index["ldesc"] ?? "", // $ldesc, + $index["element"] ?? "", // $element, + $index["previous"] ?? "", // $previous, + $index["next"] ?? "", // $next, + $index["chunk"] ?? 0, // $chunk + ); + } } } public function run() { $reader = new Reader(); $render = new Render(); + if (Index::requireIndexing()) { $format = new Index; $render->attach($format); @@ -47,9 +50,12 @@ public function run() { $render->execute($reader); $render->detach($format); } - $render->attach($this->format); - $reader->open(Config::xml_file()); - $render->execute($reader); + + if ($this->format !== null) { + $render->attach($this->format); + $reader->open(Config::xml_file()); + $render->execute($reader); + } } } diff --git a/tests/php/bug49101-1.phpt b/tests/php/bug49101-1.phpt index d1f3644d..58deb0ce 100644 --- a/tests/php/bug49101-1.phpt +++ b/tests/php/bug49101-1.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #49101 - Thick border again +Bug #49101-1 - Thick border again --FILE-- dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/bug49101-2.phpt b/tests/php/bug49101-2.phpt index 6d04d116..c1a56ea6 100644 --- a/tests/php/bug49101-2.phpt +++ b/tests/php/bug49101-2.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #49101 - Thick border again - Big XHTML +Bug #49101-2 - Thick border again - Big XHTML --FILE-- dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestBigXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/bug49102-1.phpt b/tests/php/bug49102-1.phpt index dd3f7902..d0793c70 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/php/bug49102-1.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/bug49102-1.xml"; $opts = array( @@ -24,13 +23,14 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$test = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); } -$test->run(); +$render->run(); ?> --EXPECTF-- diff --git a/tests/php/bug_doc-en_GH-3179.phpt b/tests/php/bug_doc-en_GH-3179.phpt index 41ed0478..13a0a1a7 100644 --- a/tests/php/bug_doc-en_GH-3179.phpt +++ b/tests/php/bug_doc-en_GH-3179.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/bug_doc-en_GH-3197.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/constant_links_001.phpt b/tests/php/constant_links_001.phpt index 15604229..fdc08142 100644 --- a/tests/php/constant_links_001.phpt +++ b/tests/php/constant_links_001.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/constant_links.xml"; $opts = array( @@ -34,7 +33,8 @@ $indeces = [ ], ]; -$render = new TestRender($formatclass, $opts, $extra, $indeces); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra, $indeces); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/faq001.phpt b/tests/php/faq001.phpt index f05f444b..6e171a9d 100644 --- a/tests/php/faq001.phpt +++ b/tests/php/faq001.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/faq001.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/type_rendering_001.phpt b/tests/php/type_rendering_001.phpt index 7cf4f28d..de186703 100644 --- a/tests/php/type_rendering_001.phpt +++ b/tests/php/type_rendering_001.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/type_rendering_methodsynopsis_return_types.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/type_rendering_002.phpt b/tests/php/type_rendering_002.phpt index 6309b11f..b347a283 100644 --- a/tests/php/type_rendering_002.phpt +++ b/tests/php/type_rendering_002.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/type_rendering_methodsynopsis_parameters.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/type_rendering_003.phpt b/tests/php/type_rendering_003.phpt index 88042837..86ca62ad 100644 --- a/tests/php/type_rendering_003.phpt +++ b/tests/php/type_rendering_003.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/001.phpt b/tests/xhtml/001.phpt index 785c089a..1b2c7733 100644 --- a/tests/xhtml/001.phpt +++ b/tests/xhtml/001.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/001-1.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/002.phpt b/tests/xhtml/002.phpt index 9483f1ab..fb4021f3 100644 --- a/tests/xhtml/002.phpt +++ b/tests/xhtml/002.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/002.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/003.phpt b/tests/xhtml/003.phpt index becab032..5a18c5fc 100644 --- a/tests/xhtml/003.phpt +++ b/tests/xhtml/003.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/003.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/simplelist_001.phpt b/tests/xhtml/simplelist_001.phpt index ad461a05..bf914a3b 100644 --- a/tests/xhtml/simplelist_001.phpt +++ b/tests/xhtml/simplelist_001.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/simplelist.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/whitespace_formatting_001.phpt b/tests/xhtml/whitespace_formatting_001.phpt index 5c1aa1d6..363d927c 100644 --- a/tests/xhtml/whitespace_formatting_001.phpt +++ b/tests/xhtml/whitespace_formatting_001.phpt @@ -7,7 +7,6 @@ namespace phpdotnet\phd; require_once __DIR__ . "/../setup.php"; require_once __DIR__ . "/TestChunkedXHTML.php"; -$formatclass = "TestChunkedXHTML"; $xml_file = __DIR__ . "/data/whitespace_formatting_001.xml"; $opts = array( @@ -23,7 +22,8 @@ $extra = array( "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); -$render = new TestRender($formatclass, $opts, $extra); +$format = new TestChunkedXHTML; +$render = new TestRender($format, $opts, $extra); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); From f10d03e679ff22dd3320a1cf31e25c28d041becf Mon Sep 17 00:00:00 2001 From: haszi Date: Fri, 23 Feb 2024 23:37:45 +0100 Subject: [PATCH 2/6] Add Config as a constructor dependency to TestRender Add Config as a constructor dependency to TestRender. Refactor tests to inject Config. --- tests/TestRender.php | 51 ++++++++++------------ tests/php/bug49101-1.phpt | 9 ++-- tests/php/bug49101-2.phpt | 9 ++-- tests/php/bug49102-1.phpt | 11 ++--- tests/php/bug_doc-en_GH-3179.phpt | 9 ++-- tests/php/constant_links_001.phpt | 11 ++--- tests/php/faq001.phpt | 9 ++-- tests/php/type_rendering_001.phpt | 19 ++++---- tests/php/type_rendering_002.phpt | 9 ++-- tests/php/type_rendering_003.phpt | 9 ++-- tests/xhtml/001.phpt | 9 ++-- tests/xhtml/002.phpt | 9 ++-- tests/xhtml/003.phpt | 9 ++-- tests/xhtml/simplelist_001.phpt | 9 ++-- tests/xhtml/whitespace_formatting_001.phpt | 9 ++-- 15 files changed, 73 insertions(+), 118 deletions(-) diff --git a/tests/TestRender.php b/tests/TestRender.php index 057f8d1b..e34a1177 100644 --- a/tests/TestRender.php +++ b/tests/TestRender.php @@ -4,39 +4,36 @@ class TestRender { protected ?Format $format = null; + protected Config $config; + public function __construct( ?Format $format, - array $opts, - ?array $extra = [], - ?array $indices = [] + Config $config, + ?array $indices = [], ) { - foreach ($opts as $k => $v) { - $method = "set_$k"; - Config::$method($v); - } - if (count($extra) != 0) { - Config::init($extra); - } - if ($format !== null) { $this->format = $format; - foreach ($indices as $index) { - $this->format->SQLiteIndex( - null, // $context, - null, // $index, - $index["docbook_id"] ?? "", // $id, - $index["filename"] ?? "", // $filename, - $index["parent_id"] ?? "", // $parent, - $index["sdesc"] ?? "", // $sdesc, - $index["ldesc"] ?? "", // $ldesc, - $index["element"] ?? "", // $element, - $index["previous"] ?? "", // $previous, - $index["next"] ?? "", // $next, - $index["chunk"] ?? 0, // $chunk - ); + if ($indices) { + foreach ($indices as $index) { + $this->format->SQLiteIndex( + null, // $context, + null, // $index, + $index["docbook_id"] ?? "", // $id, + $index["filename"] ?? "", // $filename, + $index["parent_id"] ?? "", // $parent, + $index["sdesc"] ?? "", // $sdesc, + $index["ldesc"] ?? "", // $ldesc, + $index["element"] ?? "", // $element, + $index["previous"] ?? "", // $previous, + $index["next"] ?? "", // $next, + $index["chunk"] ?? 0, // $chunk + ); + } } } + + $this->config = $config; } public function run() { @@ -46,14 +43,14 @@ public function run() { if (Index::requireIndexing()) { $format = new Index; $render->attach($format); - $reader->open(Config::xml_file()); + $reader->open($this->config::xml_file()); $render->execute($reader); $render->detach($format); } if ($this->format !== null) { $render->attach($this->format); - $reader->open(Config::xml_file()); + $reader->open($this->config::xml_file()); $render->execute($reader); } } diff --git a/tests/php/bug49101-1.phpt b/tests/php/bug49101-1.phpt index 58deb0ce..3497f818 100644 --- a/tests/php/bug49101-1.phpt +++ b/tests/php/bug49101-1.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/bug49101-1.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/bug49101-2.phpt b/tests/php/bug49101-2.phpt index c1a56ea6..1bbc5394 100644 --- a/tests/php/bug49101-2.phpt +++ b/tests/php/bug49101-2.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestBigXHTML.php"; $xml_file = __DIR__ . "/data/bug49101-1.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestBigXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/bug49102-1.phpt b/tests/php/bug49102-1.phpt index d0793c70..f95100d0 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/php/bug49102-1.phpt @@ -9,22 +9,19 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/bug49102-1.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", - 'language' => 'en' -); - -$extra = array( + 'language' => 'en', "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/bug_doc-en_GH-3179.phpt b/tests/php/bug_doc-en_GH-3179.phpt index 13a0a1a7..682ffe64 100644 --- a/tests/php/bug_doc-en_GH-3179.phpt +++ b/tests/php/bug_doc-en_GH-3179.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/bug_doc-en_GH-3197.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/constant_links_001.phpt b/tests/php/constant_links_001.phpt index fdc08142..300886eb 100644 --- a/tests/php/constant_links_001.phpt +++ b/tests/php/constant_links_001.phpt @@ -9,20 +9,17 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/constant_links.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); -$indeces = [ +$indices = [ [ "docbook_id" => "constant.definitely-exists", "filename" => "extensionname.constantspage", @@ -34,7 +31,7 @@ $indeces = [ ]; $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra, $indeces); +$render = new TestRender($format, new Config, $indices); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/faq001.phpt b/tests/php/faq001.phpt index 6e171a9d..c729d2e1 100644 --- a/tests/php/faq001.phpt +++ b/tests/php/faq001.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/faq001.xml"; -$opts = array( +Config::init([ "index" => false, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/type_rendering_001.phpt b/tests/php/type_rendering_001.phpt index de186703..2e223a0b 100644 --- a/tests/php/type_rendering_001.phpt +++ b/tests/php/type_rendering_001.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/type_rendering_methodsynopsis_return_types.xml"; -$opts = array( - "index" => true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", -); - -$extra = array( - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", +Config::init([ + "index" => true, + "xml_root" => dirname($xml_file), + "xml_file" => $xml_file, + "output_dir" => __DIR__ . "/output/", + "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/type_rendering_002.phpt b/tests/php/type_rendering_002.phpt index b347a283..513f7f43 100644 --- a/tests/php/type_rendering_002.phpt +++ b/tests/php/type_rendering_002.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/type_rendering_methodsynopsis_parameters.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/php/type_rendering_003.phpt b/tests/php/type_rendering_003.phpt index 86ca62ad..0b534367 100644 --- a/tests/php/type_rendering_003.phpt +++ b/tests/php/type_rendering_003.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/001.phpt b/tests/xhtml/001.phpt index 1b2c7733..b5221d4f 100644 --- a/tests/xhtml/001.phpt +++ b/tests/xhtml/001.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/001-1.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/002.phpt b/tests/xhtml/002.phpt index fb4021f3..04953b3e 100644 --- a/tests/xhtml/002.phpt +++ b/tests/xhtml/002.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/002.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/003.phpt b/tests/xhtml/003.phpt index 5a18c5fc..ea548ee5 100644 --- a/tests/xhtml/003.phpt +++ b/tests/xhtml/003.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/003.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/simplelist_001.phpt b/tests/xhtml/simplelist_001.phpt index bf914a3b..7d8f1166 100644 --- a/tests/xhtml/simplelist_001.phpt +++ b/tests/xhtml/simplelist_001.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/simplelist.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); diff --git a/tests/xhtml/whitespace_formatting_001.phpt b/tests/xhtml/whitespace_formatting_001.phpt index 363d927c..0211b196 100644 --- a/tests/xhtml/whitespace_formatting_001.phpt +++ b/tests/xhtml/whitespace_formatting_001.phpt @@ -9,21 +9,18 @@ require_once __DIR__ . "/TestChunkedXHTML.php"; $xml_file = __DIR__ . "/data/whitespace_formatting_001.xml"; -$opts = array( +Config::init([ "index" => true, "xml_root" => dirname($xml_file), "xml_file" => $xml_file, "output_dir" => __DIR__ . "/output/", -); - -$extra = array( "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); +]); $format = new TestChunkedXHTML; -$render = new TestRender($format, $opts, $extra); +$render = new TestRender($format, new Config); if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { mkdir($opts["output_dir"], 0755); From 8a24dd106ed13efcaa037ede0e1daa44d2511f1b Mon Sep 17 00:00:00 2001 From: haszi Date: Fri, 23 Feb 2024 23:40:39 +0100 Subject: [PATCH 3/6] Add Index as an optional constructor dependency to TestRender --- tests/TestRender.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/TestRender.php b/tests/TestRender.php index e34a1177..b01271c1 100644 --- a/tests/TestRender.php +++ b/tests/TestRender.php @@ -6,10 +6,13 @@ class TestRender { protected Config $config; + protected ?Index $index = null; + public function __construct( - ?Format $format, + ?Format $format = null, Config $config, ?array $indices = [], + ?Index $index = null, ) { if ($format !== null) { $this->format = $format; @@ -34,18 +37,21 @@ public function __construct( } $this->config = $config; + + if ($index !== null) { + $this->index = $index; + } } public function run() { $reader = new Reader(); $render = new Render(); - if (Index::requireIndexing()) { - $format = new Index; - $render->attach($format); + if ($this->index !== null && $this->index::requireIndexing()) { + $render->attach($this->index); $reader->open($this->config::xml_file()); $render->execute($reader); - $render->detach($format); + $render->detach($this->index); } if ($this->format !== null) { From 7a94797e6aaf79107557b8760571353018427b7b Mon Sep 17 00:00:00 2001 From: haszi Date: Fri, 23 Feb 2024 23:50:52 +0100 Subject: [PATCH 4/6] TestRender to extend Render --- tests/TestRender.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/TestRender.php b/tests/TestRender.php index b01271c1..f7217bf2 100644 --- a/tests/TestRender.php +++ b/tests/TestRender.php @@ -1,7 +1,7 @@ index !== null && $this->index::requireIndexing()) { - $render->attach($this->index); + $this->attach($this->index); $reader->open($this->config::xml_file()); - $render->execute($reader); - $render->detach($this->index); + $this->execute($reader); + $this->detach($this->index); } if ($this->format !== null) { - $render->attach($this->format); + $this->attach($this->format); $reader->open($this->config::xml_file()); - $render->execute($reader); + $this->execute($reader); } } } From 547fc20f4b7888911b2fd125faf2e6935ff76b81 Mon Sep 17 00:00:00 2001 From: haszi Date: Sun, 25 Feb 2024 19:20:28 +0100 Subject: [PATCH 5/6] Config to allow calling instance methods --- phpdotnet/phd/Config.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index a80a0a8b..400fca73 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -140,6 +140,10 @@ public static function __callStatic($name, $params) : NULL; } + public function __call($name, $params) { + return self::__callStatic($name, $params); + } + public static function getSupportedPackages() { $packageList = array(); foreach(Config::package_dirs() as $dir) { @@ -183,5 +187,3 @@ public static function copyright() { } } - - From c5fce08ad9e96a214db854541291ebca1dc4442d Mon Sep 17 00:00:00 2001 From: haszi Date: Sun, 25 Feb 2024 19:26:07 +0100 Subject: [PATCH 6/6] Refactor test helpers and test directory structure Refactor TestRender to use only constructor injected objects. Rename test format helper classes to indicate which package they belong to. Move TestRender and all format helper classes into the phpdotnet phd directory to enable autoloading. Remove all unnecessary lines from setup.php. Restructure test directory to follow the structure of the tested classes. --- phpdotnet/phd/Index.php | 3 - .../phd/TestGenericChunkedXHTML.php | 2 +- .../phd/TestPHPBigXHTML.php | 4 +- .../phd/TestPHPChunkedXHTML.php | 4 +- phpdotnet/phd/TestRender.php | 33 ++++++++++ tests/TestRender.php | 64 ------------------- tests/{xhtml => package/generic}/001.phpt | 23 ++----- tests/{xhtml => package/generic}/002.phpt | 23 ++----- tests/{xhtml => package/generic}/003.phpt | 23 ++----- .../{xhtml => package/generic}/data/001-1.xml | 0 tests/{xhtml => package/generic}/data/002.xml | 0 tests/{xhtml => package/generic}/data/003.xml | 0 .../generic}/data/simplelist.xml | 0 .../data/whitespace_formatting_001.xml | 0 .../generic}/simplelist_001.phpt | 21 ++---- .../generic}/whitespace_formatting_001.phpt | 21 ++---- tests/{ => package}/php/bug49101-1.phpt | 23 ++----- tests/{ => package}/php/bug49101-2.phpt | 23 ++----- tests/{ => package}/php/bug49102-1.phpt | 24 ++----- tests/package/php/bug_doc-en_GH-3179.phpt | 27 ++++++++ .../{ => package}/php/constant_links_001.phpt | 34 +++++----- tests/{ => package}/php/data/acronyms.xml | 0 tests/{ => package}/php/data/bug49101-1.xml | 0 tests/{ => package}/php/data/bug49102-1.xml | 0 .../php/data/bug_doc-en_GH-3197.xml | 0 .../{ => package}/php/data/constant_links.xml | 0 tests/{ => package}/php/data/faq001.xml | 0 ...torsynopsis_parameters-and-return-type.xml | 0 ...pe_rendering_methodsynopsis_parameters.xml | 0 ..._rendering_methodsynopsis_return_types.xml | 0 .../php/data/variablelist_rendering_001.xml | 0 tests/{ => package}/php/data/version.xml | 0 tests/{ => package}/php/faq001.phpt | 21 ++---- .../{ => package}/php/type_rendering_001.phpt | 23 ++----- .../{ => package}/php/type_rendering_002.phpt | 23 ++----- .../{ => package}/php/type_rendering_003.phpt | 23 ++----- .../php/variablelist_rendering_001.phpt | 24 ++----- tests/php/bug_doc-en_GH-3179.phpt | 40 ------------ tests/setup.php | 16 ++--- 39 files changed, 149 insertions(+), 373 deletions(-) rename tests/xhtml/TestChunkedXHTML.php => phpdotnet/phd/TestGenericChunkedXHTML.php (92%) rename tests/php/TestBigXHTML.php => phpdotnet/phd/TestPHPBigXHTML.php (95%) rename tests/php/TestChunkedXHTML.php => phpdotnet/phd/TestPHPChunkedXHTML.php (93%) create mode 100644 phpdotnet/phd/TestRender.php delete mode 100644 tests/TestRender.php rename tests/{xhtml => package/generic}/001.phpt (66%) rename tests/{xhtml => package/generic}/002.phpt (86%) rename tests/{xhtml => package/generic}/003.phpt (90%) rename tests/{xhtml => package/generic}/data/001-1.xml (100%) rename tests/{xhtml => package/generic}/data/002.xml (100%) rename tests/{xhtml => package/generic}/data/003.xml (100%) rename tests/{xhtml => package/generic}/data/simplelist.xml (100%) rename tests/{xhtml => package/generic}/data/whitespace_formatting_001.xml (100%) rename tests/{xhtml => package/generic}/simplelist_001.phpt (68%) rename tests/{xhtml => package/generic}/whitespace_formatting_001.phpt (81%) rename tests/{ => package}/php/bug49101-1.phpt (66%) rename tests/{ => package}/php/bug49101-2.phpt (71%) rename tests/{ => package}/php/bug49102-1.phpt (84%) create mode 100644 tests/package/php/bug_doc-en_GH-3179.phpt rename tests/{ => package}/php/constant_links_001.phpt (62%) rename tests/{ => package}/php/data/acronyms.xml (100%) rename tests/{ => package}/php/data/bug49101-1.xml (100%) rename tests/{ => package}/php/data/bug49102-1.xml (100%) rename tests/{ => package}/php/data/bug_doc-en_GH-3197.xml (100%) rename tests/{ => package}/php/data/constant_links.xml (100%) rename tests/{ => package}/php/data/faq001.xml (100%) rename tests/{ => package}/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml (100%) rename tests/{ => package}/php/data/type_rendering_methodsynopsis_parameters.xml (100%) rename tests/{ => package}/php/data/type_rendering_methodsynopsis_return_types.xml (100%) rename tests/{ => package}/php/data/variablelist_rendering_001.xml (100%) rename tests/{ => package}/php/data/version.xml (100%) rename tests/{ => package}/php/faq001.phpt (73%) rename tests/{ => package}/php/type_rendering_001.phpt (83%) rename tests/{ => package}/php/type_rendering_002.phpt (88%) rename tests/{ => package}/php/type_rendering_003.phpt (90%) rename tests/{ => package}/php/variablelist_rendering_001.phpt (66%) delete mode 100644 tests/php/bug_doc-en_GH-3179.phpt diff --git a/phpdotnet/phd/Index.php b/phpdotnet/phd/Index.php index 0181067a..e0d119d3 100644 --- a/phpdotnet/phd/Index.php +++ b/phpdotnet/phd/Index.php @@ -527,6 +527,3 @@ public function setMembership($membership) { } } - - - diff --git a/tests/xhtml/TestChunkedXHTML.php b/phpdotnet/phd/TestGenericChunkedXHTML.php similarity index 92% rename from tests/xhtml/TestChunkedXHTML.php rename to phpdotnet/phd/TestGenericChunkedXHTML.php index 21badb29..212af20a 100644 --- a/tests/xhtml/TestChunkedXHTML.php +++ b/phpdotnet/phd/TestGenericChunkedXHTML.php @@ -1,7 +1,7 @@ index && $this->index::requireIndexing()) { + if (!file_exists($this->config->output_dir())) { + mkdir($this->config->output_dir(), 0755); + } + $this->attach($this->index); + $this->reader->open($this->config->xml_file()); + $this->execute($this->reader); + $this->detach($this->index); + } + + if ($this->format !== null) { + $this->attach($this->format); + $this->reader->open($this->config->xml_file()); + $this->execute($this->reader); + } + } + + public function getIndex(): ?Index { + return $this->index; + } +} diff --git a/tests/TestRender.php b/tests/TestRender.php deleted file mode 100644 index f7217bf2..00000000 --- a/tests/TestRender.php +++ /dev/null @@ -1,64 +0,0 @@ -format = $format; - - if ($indices) { - foreach ($indices as $index) { - $this->format->SQLiteIndex( - null, // $context, - null, // $index, - $index["docbook_id"] ?? "", // $id, - $index["filename"] ?? "", // $filename, - $index["parent_id"] ?? "", // $parent, - $index["sdesc"] ?? "", // $sdesc, - $index["ldesc"] ?? "", // $ldesc, - $index["element"] ?? "", // $element, - $index["previous"] ?? "", // $previous, - $index["next"] ?? "", // $next, - $index["chunk"] ?? 0, // $chunk - ); - } - } - } - - $this->config = $config; - - if ($index !== null) { - $this->index = $index; - } - } - - public function run() { - $reader = new Reader(); - - if ($this->index !== null && $this->index::requireIndexing()) { - $this->attach($this->index); - $reader->open($this->config::xml_file()); - $this->execute($reader); - $this->detach($this->index); - } - - if ($this->format !== null) { - $this->attach($this->format); - $reader->open($this->config::xml_file()); - $this->execute($reader); - } - } -} - - diff --git a/tests/xhtml/001.phpt b/tests/package/generic/001.phpt similarity index 66% rename from tests/xhtml/001.phpt rename to tests/package/generic/001.phpt index b5221d4f..0f80b0c6 100644 --- a/tests/xhtml/001.phpt +++ b/tests/package/generic/001.phpt @@ -4,27 +4,14 @@ CALS Table rendering true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestGenericChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/xhtml/002.phpt b/tests/package/generic/002.phpt similarity index 86% rename from tests/xhtml/002.phpt rename to tests/package/generic/002.phpt index 04953b3e..b00e65d1 100644 --- a/tests/xhtml/002.phpt +++ b/tests/package/generic/002.phpt @@ -4,27 +4,14 @@ CALS Table rendering#002 true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestGenericChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/xhtml/003.phpt b/tests/package/generic/003.phpt similarity index 90% rename from tests/xhtml/003.phpt rename to tests/package/generic/003.phpt index ea548ee5..512c1e3e 100644 --- a/tests/xhtml/003.phpt +++ b/tests/package/generic/003.phpt @@ -4,27 +4,14 @@ CALS Table rendering#003 true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestGenericChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/xhtml/data/001-1.xml b/tests/package/generic/data/001-1.xml similarity index 100% rename from tests/xhtml/data/001-1.xml rename to tests/package/generic/data/001-1.xml diff --git a/tests/xhtml/data/002.xml b/tests/package/generic/data/002.xml similarity index 100% rename from tests/xhtml/data/002.xml rename to tests/package/generic/data/002.xml diff --git a/tests/xhtml/data/003.xml b/tests/package/generic/data/003.xml similarity index 100% rename from tests/xhtml/data/003.xml rename to tests/package/generic/data/003.xml diff --git a/tests/xhtml/data/simplelist.xml b/tests/package/generic/data/simplelist.xml similarity index 100% rename from tests/xhtml/data/simplelist.xml rename to tests/package/generic/data/simplelist.xml diff --git a/tests/xhtml/data/whitespace_formatting_001.xml b/tests/package/generic/data/whitespace_formatting_001.xml similarity index 100% rename from tests/xhtml/data/whitespace_formatting_001.xml rename to tests/package/generic/data/whitespace_formatting_001.xml diff --git a/tests/xhtml/simplelist_001.phpt b/tests/package/generic/simplelist_001.phpt similarity index 68% rename from tests/xhtml/simplelist_001.phpt rename to tests/package/generic/simplelist_001.phpt index 7d8f1166..5be5acdb 100644 --- a/tests/xhtml/simplelist_001.phpt +++ b/tests/package/generic/simplelist_001.phpt @@ -4,27 +4,14 @@ Simplelist rendering 001 - Types and columns true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); +Config::init(["xml_file" => $xml_file]); -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +$format = new TestGenericChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/xhtml/whitespace_formatting_001.phpt b/tests/package/generic/whitespace_formatting_001.phpt similarity index 81% rename from tests/xhtml/whitespace_formatting_001.phpt rename to tests/package/generic/whitespace_formatting_001.phpt index 0211b196..8c698aca 100644 --- a/tests/xhtml/whitespace_formatting_001.phpt +++ b/tests/package/generic/whitespace_formatting_001.phpt @@ -4,27 +4,14 @@ Whitespace formatting 001 true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); +Config::init(["xml_file" => $xml_file]); -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +$format = new TestGenericChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/bug49101-1.phpt b/tests/package/php/bug49101-1.phpt similarity index 66% rename from tests/php/bug49101-1.phpt rename to tests/package/php/bug49101-1.phpt index 3497f818..b8330949 100644 --- a/tests/php/bug49101-1.phpt +++ b/tests/package/php/bug49101-1.phpt @@ -4,27 +4,14 @@ Bug #49101-1 - Thick border again true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); +Config::init(["xml_file" => $xml_file]); -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> @@ -88,3 +75,5 @@ Content: + + diff --git a/tests/php/bug49101-2.phpt b/tests/package/php/bug49101-2.phpt similarity index 71% rename from tests/php/bug49101-2.phpt rename to tests/package/php/bug49101-2.phpt index 1bbc5394..b44dd02c 100644 --- a/tests/php/bug49101-2.phpt +++ b/tests/package/php/bug49101-2.phpt @@ -4,27 +4,14 @@ Bug #49101-2 - Thick border again - Big XHTML true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestBigXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestPHPBigXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/bug49102-1.phpt b/tests/package/php/bug49102-1.phpt similarity index 84% rename from tests/php/bug49102-1.phpt rename to tests/package/php/bug49102-1.phpt index f95100d0..8b1f032d 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/package/php/bug49102-1.phpt @@ -4,28 +4,14 @@ Bug #49102 - Class reference pages don't normalize the methodnames in PhD trunk/ true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - 'language' => 'en', - "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/package/php/bug_doc-en_GH-3179.phpt b/tests/package/php/bug_doc-en_GH-3179.phpt new file mode 100644 index 00000000..68cdef2a --- /dev/null +++ b/tests/package/php/bug_doc-en_GH-3179.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug doc-en GH-3197 +--FILE-- + $xml_file]); + +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); + +$render->run(); +?> +--EXPECT-- +Filename: bug_doc-en_GH-3179.html +Content: +
+
+
method_name(): void
+ +
+ +
diff --git a/tests/php/constant_links_001.phpt b/tests/package/php/constant_links_001.phpt similarity index 62% rename from tests/php/constant_links_001.phpt rename to tests/package/php/constant_links_001.phpt index 300886eb..6e40f8b9 100644 --- a/tests/php/constant_links_001.phpt +++ b/tests/package/php/constant_links_001.phpt @@ -4,20 +4,11 @@ Constant links 001 true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); +Config::init(["xml_file" => $xml_file]); $indices = [ [ @@ -30,13 +21,26 @@ $indices = [ ], ]; -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config, $indices); +$format = new TestPHPChunkedXHTML; -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); +foreach ($indices as $index) { + $format->SQLiteIndex( + null, // $context, + null, // $index, + $index["docbook_id"] ?? "", // $id, + $index["filename"] ?? "", // $filename, + $index["parent_id"] ?? "", // $parent, + $index["sdesc"] ?? "", // $sdesc, + $index["ldesc"] ?? "", // $ldesc, + $index["element"] ?? "", // $element, + $index["previous"] ?? "", // $previous, + $index["next"] ?? "", // $next, + $index["chunk"] ?? 0, // $chunk + ); } +$render = new TestRender(new Reader, new Config, $format); + $render->run(); ?> --EXPECTF-- diff --git a/tests/php/data/acronyms.xml b/tests/package/php/data/acronyms.xml similarity index 100% rename from tests/php/data/acronyms.xml rename to tests/package/php/data/acronyms.xml diff --git a/tests/php/data/bug49101-1.xml b/tests/package/php/data/bug49101-1.xml similarity index 100% rename from tests/php/data/bug49101-1.xml rename to tests/package/php/data/bug49101-1.xml diff --git a/tests/php/data/bug49102-1.xml b/tests/package/php/data/bug49102-1.xml similarity index 100% rename from tests/php/data/bug49102-1.xml rename to tests/package/php/data/bug49102-1.xml diff --git a/tests/php/data/bug_doc-en_GH-3197.xml b/tests/package/php/data/bug_doc-en_GH-3197.xml similarity index 100% rename from tests/php/data/bug_doc-en_GH-3197.xml rename to tests/package/php/data/bug_doc-en_GH-3197.xml diff --git a/tests/php/data/constant_links.xml b/tests/package/php/data/constant_links.xml similarity index 100% rename from tests/php/data/constant_links.xml rename to tests/package/php/data/constant_links.xml diff --git a/tests/php/data/faq001.xml b/tests/package/php/data/faq001.xml similarity index 100% rename from tests/php/data/faq001.xml rename to tests/package/php/data/faq001.xml diff --git a/tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml b/tests/package/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml similarity index 100% rename from tests/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml rename to tests/package/php/data/type_rendering_constructorsynopsis_parameters-and-return-type.xml diff --git a/tests/php/data/type_rendering_methodsynopsis_parameters.xml b/tests/package/php/data/type_rendering_methodsynopsis_parameters.xml similarity index 100% rename from tests/php/data/type_rendering_methodsynopsis_parameters.xml rename to tests/package/php/data/type_rendering_methodsynopsis_parameters.xml diff --git a/tests/php/data/type_rendering_methodsynopsis_return_types.xml b/tests/package/php/data/type_rendering_methodsynopsis_return_types.xml similarity index 100% rename from tests/php/data/type_rendering_methodsynopsis_return_types.xml rename to tests/package/php/data/type_rendering_methodsynopsis_return_types.xml diff --git a/tests/php/data/variablelist_rendering_001.xml b/tests/package/php/data/variablelist_rendering_001.xml similarity index 100% rename from tests/php/data/variablelist_rendering_001.xml rename to tests/package/php/data/variablelist_rendering_001.xml diff --git a/tests/php/data/version.xml b/tests/package/php/data/version.xml similarity index 100% rename from tests/php/data/version.xml rename to tests/package/php/data/version.xml diff --git a/tests/php/faq001.phpt b/tests/package/php/faq001.phpt similarity index 73% rename from tests/php/faq001.phpt rename to tests/package/php/faq001.phpt index c729d2e1..5f221630 100644 --- a/tests/php/faq001.phpt +++ b/tests/package/php/faq001.phpt @@ -4,27 +4,14 @@ Testing a simple FAQ false, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __DIR__ . "/../../phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); +Config::init(["xml_file" => $xml_file]); -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/type_rendering_001.phpt b/tests/package/php/type_rendering_001.phpt similarity index 83% rename from tests/php/type_rendering_001.phpt rename to tests/package/php/type_rendering_001.phpt index 2e223a0b..ed29ea18 100644 --- a/tests/php/type_rendering_001.phpt +++ b/tests/package/php/type_rendering_001.phpt @@ -4,27 +4,14 @@ Type rendering 001 - Methodsynopsis return types true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/type_rendering_002.phpt b/tests/package/php/type_rendering_002.phpt similarity index 88% rename from tests/php/type_rendering_002.phpt rename to tests/package/php/type_rendering_002.phpt index 513f7f43..d1a51531 100644 --- a/tests/php/type_rendering_002.phpt +++ b/tests/package/php/type_rendering_002.phpt @@ -4,27 +4,14 @@ Type rendering 002 - Methodsynopsis parameters and parameter types true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/type_rendering_003.phpt b/tests/package/php/type_rendering_003.phpt similarity index 90% rename from tests/php/type_rendering_003.phpt rename to tests/package/php/type_rendering_003.phpt index 0b534367..d4467856 100644 --- a/tests/php/type_rendering_003.phpt +++ b/tests/package/php/type_rendering_003.phpt @@ -4,27 +4,14 @@ Type rendering 003 - Constructorsynopsis parameters and parameter types true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +Config::init(["xml_file" => $xml_file]); + +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/variablelist_rendering_001.phpt b/tests/package/php/variablelist_rendering_001.phpt similarity index 66% rename from tests/php/variablelist_rendering_001.phpt rename to tests/package/php/variablelist_rendering_001.phpt index 5855f264..b5fece9e 100644 --- a/tests/php/variablelist_rendering_001.phpt +++ b/tests/package/php/variablelist_rendering_001.phpt @@ -4,30 +4,14 @@ Variablelist rendering 001 true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", -); +Config::init(["xml_file" => $xml_file]); -$extra = array( - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -); - -$render = new TestRender($formatclass, $opts, $extra); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +$format = new TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); $render->run(); ?> diff --git a/tests/php/bug_doc-en_GH-3179.phpt b/tests/php/bug_doc-en_GH-3179.phpt deleted file mode 100644 index 682ffe64..00000000 --- a/tests/php/bug_doc-en_GH-3179.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Bug doc-en GH-3197 ---FILE-- - true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", - "lang_dir" => __PHDDIR__ . "phpdotnet/phd/data/langs/", - "phpweb_version_filename" => dirname($xml_file) . '/version.xml', - "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', -]); - -$format = new TestChunkedXHTML; -$render = new TestRender($format, new Config); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} - -$render->run(); -?> ---EXPECT-- -Filename: bug_doc-en_GH-3179.html -Content: -
-
-
method_name(): void
- -
- -
diff --git a/tests/setup.php b/tests/setup.php index b5612000..ea392add 100644 --- a/tests/setup.php +++ b/tests/setup.php @@ -5,19 +5,13 @@ define("__INSTALLDIR__", "@php_dir@" == "@"."php_dir@" ? dirname(dirname(__DIR__)) : "@php_dir@"); require_once __PHDDIR__ . "phpdotnet" . DIRECTORY_SEPARATOR . "phd" . DIRECTORY_SEPARATOR . "Autoloader.php"; -require_once __PHDDIR__ . "phpdotnet" . DIRECTORY_SEPARATOR . "phd" . DIRECTORY_SEPARATOR . "functions.php"; -require_once __PHDDIR__ . "tests" . DIRECTORY_SEPARATOR . "TestRender.php"; - spl_autoload_register(["phpdotnet\\phd\\Autoloader", "autoload"]); +require_once __PHDDIR__ . "phpdotnet" . DIRECTORY_SEPARATOR . "phd" . DIRECTORY_SEPARATOR . "functions.php"; + Config::init([ - "lang_dir" => __PHDDIR__ . DIRECTORY_SEPARATOR . "phpdotnet" . DIRECTORY_SEPARATOR - . "phd" . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR - . "langs" . DIRECTORY_SEPARATOR, - "phpweb_version_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'version.xml', - "phpweb_acronym_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'acronyms.xml', - "phpweb_sources_filename" => Config::xml_root() . DIRECTORY_SEPARATOR . 'sources.xml', + "lang_dir" => __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR + . "phpdotnet" . DIRECTORY_SEPARATOR . "phd" . DIRECTORY_SEPARATOR + . "data" . DIRECTORY_SEPARATOR . "langs" . DIRECTORY_SEPARATOR, "package_dirs" => [__PHDDIR__, __INSTALLDIR__], ]); - -