From b703f50bdf66731d6442530e53ab3908a86508b2 Mon Sep 17 00:00:00 2001 From: haszi Date: Mon, 26 Feb 2024 16:12:03 +0100 Subject: [PATCH] Refactor test helpers and test files (#104) * 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. * Add Config as a constructor dependency to TestRender Add Config as a constructor dependency to TestRender. Refactor tests to inject Config. * Add Index as an optional constructor dependency to TestRender * TestRender to extend Render * Config to allow calling instance methods * 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. --------- Co-authored-by: haszi --- phpdotnet/phd/Config.php | 6 +- 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 | 56 ------------------- tests/{xhtml => package/generic}/001.phpt | 24 ++------ tests/{xhtml => package/generic}/002.phpt | 24 ++------ tests/{xhtml => package/generic}/003.phpt | 24 ++------ .../{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 | 24 ++------ .../generic}/whitespace_formatting_001.phpt | 24 ++------ tests/{ => package}/php/bug49101-1.phpt | 28 +++------- tests/{ => package}/php/bug49101-2.phpt | 26 ++------- tests/{ => package}/php/bug49102-1.phpt | 27 ++------- tests/package/php/bug_doc-en_GH-3179.phpt | 27 +++++++++ .../{ => package}/php/constant_links_001.phpt | 39 ++++++------- 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 | 24 ++------ .../{ => package}/php/type_rendering_001.phpt | 24 ++------ .../{ => package}/php/type_rendering_002.phpt | 24 ++------ .../{ => package}/php/type_rendering_003.phpt | 24 ++------ .../php/variablelist_rendering_001.phpt | 24 ++------ tests/php/bug_doc-en_GH-3179.phpt | 43 -------------- tests/setup.php | 16 ++---- 40 files changed, 149 insertions(+), 405 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 (85%) 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 (67%) rename tests/{xhtml => package/generic}/whitespace_formatting_001.phpt (80%) rename tests/{ => package}/php/bug49101-1.phpt (64%) rename tests/{ => package}/php/bug49101-2.phpt (68%) rename tests/{ => package}/php/bug49102-1.phpt (83%) create mode 100644 tests/package/php/bug_doc-en_GH-3179.phpt rename tests/{ => package}/php/constant_links_001.phpt (61%) 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/Config.php b/phpdotnet/phd/Config.php index a80a0a8b2..400fca73f 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() { } } - - diff --git a/phpdotnet/phd/Index.php b/phpdotnet/phd/Index.php index 0181067a0..e0d119d3a 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 21badb292..212af20a7 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 6c74f8dca..000000000 --- a/tests/TestRender.php +++ /dev/null @@ -1,56 +0,0 @@ - $v) { - $method = "set_$k"; - Config::$method($v); - } - 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 - ); - } - } - - public function run() { - $reader = new Reader(); - $render = new Render(); - if (Index::requireIndexing()) { - $format = new Index; - $render->attach($format); - $reader->open(Config::xml_file()); - $render->execute($reader); - $render->detach($format); - } - $render->attach($this->format); - $reader->open(Config::xml_file()); - $render->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 785c089ab..0f80b0c6d 100644 --- a/tests/xhtml/001.phpt +++ b/tests/package/generic/001.phpt @@ -4,30 +4,14 @@ CALS Table rendering 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 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 85% rename from tests/xhtml/002.phpt rename to tests/package/generic/002.phpt index 9483f1abb..b00e65d13 100644 --- a/tests/xhtml/002.phpt +++ b/tests/package/generic/002.phpt @@ -4,30 +4,14 @@ CALS Table rendering#002 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 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 becab0328..512c1e3e2 100644 --- a/tests/xhtml/003.phpt +++ b/tests/package/generic/003.phpt @@ -4,30 +4,14 @@ CALS Table rendering#003 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 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 67% rename from tests/xhtml/simplelist_001.phpt rename to tests/package/generic/simplelist_001.phpt index ad461a059..5be5acdbe 100644 --- a/tests/xhtml/simplelist_001.phpt +++ b/tests/package/generic/simplelist_001.phpt @@ -4,30 +4,14 @@ Simplelist rendering 001 - Types and columns 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 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 80% rename from tests/xhtml/whitespace_formatting_001.phpt rename to tests/package/generic/whitespace_formatting_001.phpt index 5c1aa1d69..8c698acaa 100644 --- a/tests/xhtml/whitespace_formatting_001.phpt +++ b/tests/package/generic/whitespace_formatting_001.phpt @@ -4,30 +4,14 @@ Whitespace formatting 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 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 64% rename from tests/php/bug49101-1.phpt rename to tests/package/php/bug49101-1.phpt index d1f3644d3..b8330949b 100644 --- a/tests/php/bug49101-1.phpt +++ b/tests/package/php/bug49101-1.phpt @@ -1,33 +1,17 @@ --TEST-- -Bug #49101 - Thick border again +Bug #49101-1 - Thick border again --FILE-- true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", -); +Config::init(["xml_file" => $xml_file]); -$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', -); - -$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(); ?> @@ -91,3 +75,5 @@ Content: + + diff --git a/tests/php/bug49101-2.phpt b/tests/package/php/bug49101-2.phpt similarity index 68% rename from tests/php/bug49101-2.phpt rename to tests/package/php/bug49101-2.phpt index 6d04d116d..b44dd02c8 100644 --- a/tests/php/bug49101-2.phpt +++ b/tests/package/php/bug49101-2.phpt @@ -1,33 +1,17 @@ --TEST-- -Bug #49101 - Thick border again - Big XHTML +Bug #49101-2 - Thick border again - Big XHTML --FILE-- true, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", -); +Config::init(["xml_file" => $xml_file]); -$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', -); - -$render = new TestRender($formatclass, $opts, $extra); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} +$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 83% rename from tests/php/bug49102-1.phpt rename to tests/package/php/bug49102-1.phpt index dd3f79022..8b1f032d1 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/package/php/bug49102-1.phpt @@ -4,33 +4,16 @@ 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' -); +Config::init(["xml_file" => $xml_file]); -$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 TestPHPChunkedXHTML; +$render = new TestRender(new Reader, new Config, $format); -$test = new TestRender($formatclass, $opts, $extra); - -if (Index::requireIndexing() && !file_exists($opts["output_dir"])) { - mkdir($opts["output_dir"], 0755); -} - -$test->run(); +$render->run(); ?> --EXPECTF-- 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 000000000..68cdef2a5 --- /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 61% rename from tests/php/constant_links_001.phpt rename to tests/package/php/constant_links_001.phpt index 156042296..6e40f8b90 100644 --- a/tests/php/constant_links_001.phpt +++ b/tests/package/php/constant_links_001.phpt @@ -4,26 +4,13 @@ Constant links 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', -); - -$indeces = [ +$indices = [ [ "docbook_id" => "constant.definitely-exists", "filename" => "extensionname.constantspage", @@ -34,12 +21,26 @@ $indeces = [ ], ]; -$render = new TestRender($formatclass, $opts, $extra, $indeces); +$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 f05f444b2..5f2216305 100644 --- a/tests/php/faq001.phpt +++ b/tests/package/php/faq001.phpt @@ -4,30 +4,14 @@ Testing a simple FAQ false, - "xml_root" => dirname($xml_file), - "xml_file" => $xml_file, - "output_dir" => __DIR__ . "/output/", -); +Config::init(["xml_file" => $xml_file]); -$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', -); - -$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/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 7cf4f28d9..ed29ea180 100644 --- a/tests/php/type_rendering_001.phpt +++ b/tests/package/php/type_rendering_001.phpt @@ -4,30 +4,14 @@ Type rendering 001 - Methodsynopsis return types 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/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 6309b11fc..d1a515316 100644 --- a/tests/php/type_rendering_002.phpt +++ b/tests/package/php/type_rendering_002.phpt @@ -4,30 +4,14 @@ Type rendering 002 - Methodsynopsis parameters and parameter types 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/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 880428376..d4467856e 100644 --- a/tests/php/type_rendering_003.phpt +++ b/tests/package/php/type_rendering_003.phpt @@ -4,30 +4,14 @@ Type rendering 003 - Constructorsynopsis parameters and parameter types 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/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 5855f264a..b5fece9e0 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 41ed0478b..000000000 --- a/tests/php/bug_doc-en_GH-3179.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Bug doc-en GH-3197 ---FILE-- - 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', -); - -$render = new TestRender($formatclass, $opts, $extra); - -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 b5612000d..ea392addc 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__], ]); - -