Skip to content

Fix tests #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace phpdotnet\phd;

#[\AllowDynamicProperties]
abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
private $myelementmap = array( /* {{{ */
'abstract' => 'div', /* Docbook-xsl prints "abstract"... */
Expand Down Expand Up @@ -794,7 +795,7 @@ public function format_container_chunk_top($open, $name, $attrs, $props) {
$this->CURRENT_CHUNK = $id;
$this->notify(Render::CHUNK, Render::CLOSE);
$toc = "";
if (!in_array($id, $this->TOC_WRITTEN)) {
if (!in_array($id, $this->TOC_WRITTEN ?? [])) {
$toc = $this->createTOC($id, $name, $props);
}

Expand Down Expand Up @@ -832,7 +833,7 @@ public function format_container_chunk_below($open, $name, $attrs, $props) {

$toc = '<ol>';
$desc = "";
if (!in_array($id, $this->TOC_WRITTEN)) {
if (!in_array($id, $this->TOC_WRITTEN ?? [])) {
$toc = $this->createTOC($id, $name, $props);
}
$toc .= "</ol>\n";
Expand Down
4 changes: 2 additions & 2 deletions phpdotnet/phd/Package/PHP/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ private function isChunkedByAttributes(array $attributes): bool {
}

public function format_container_chunk($open, $name, $attrs, $props) {
$this->CURRENT_CHUNK = $this->CURRENT_ID = $id = $attrs[Reader::XMLNS_XML]["id"];
$this->CURRENT_CHUNK = $this->CURRENT_ID = $id = $attrs[Reader::XMLNS_XML]["id"] ?? '';

if ($this->isChunkedByAttributes($attrs)) {
$this->cchunk = $this->dchunk;
Expand Down Expand Up @@ -809,7 +809,7 @@ public function format_container_chunk($open, $name, $attrs, $props) {
}

public function format_root_chunk($open, $name, $attrs) {
$this->CURRENT_CHUNK = $this->CURRENT_ID = $id = $attrs[Reader::XMLNS_XML]["id"];
$this->CURRENT_CHUNK = $this->CURRENT_ID = $id = $attrs[Reader::XMLNS_XML]["id"] ?? '';
if ($open) {
$this->notify(Render::CHUNK, Render::OPEN);
return '<div id="'.$id.'" class="'.$name.'">';
Expand Down
4 changes: 4 additions & 0 deletions tests/php/TestChunkedXHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function writeChunk($id, $fp) {
$content = "\n";
$content .= stream_get_contents($fp);

if ($id === "") {
$filename = Config::xml_file();
}

echo "Filename: " . basename($filename) . "\n";
echo "Content:" . $content . "\n";
}
Expand Down
6 changes: 5 additions & 1 deletion tests/php/bug49101-1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Bug #49101 - Thick border again
namespace phpdotnet\phd;

require_once __DIR__ . "/../setup.php";
require_once __DIR__ . "/../TestRender.php";
require_once __DIR__ . "/TestChunkedXHTML.php";

$formatclass = "TestChunkedXHTML";
Expand All @@ -25,6 +24,11 @@ $extra = array(
);

$render = new TestRender($formatclass, $opts, $extra);

if (Index::requireIndexing() && !file_exists($opts["output_dir"])) {
mkdir($opts["output_dir"], 0755);
}

$render->run();
?>
--EXPECT--
Expand Down
6 changes: 5 additions & 1 deletion tests/php/bug49101-2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Bug #49101 - Thick border again - Big XHTML
namespace phpdotnet\phd;

require_once __DIR__ . "/../setup.php";
require_once __DIR__ . "/../TestRender.php";
require_once __DIR__ . "/TestBigXHTML.php";

$formatclass = "TestBigXHTML";
Expand All @@ -25,6 +24,11 @@ $extra = array(
);

$render = new TestRender($formatclass, $opts, $extra);

if (Index::requireIndexing() && !file_exists($opts["output_dir"])) {
mkdir($opts["output_dir"], 0755);
}

$render->run();
?>
--EXPECTF--
Expand Down
75 changes: 23 additions & 52 deletions tests/php/bug49102-1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Bug #49102 - Class reference pages don't normalize the methodnames in PhD trunk/
namespace phpdotnet\phd;

require_once __DIR__ . "/../setup.php";
require_once __DIR__ . "/../TestRender.php";
require_once __DIR__ . "/TestChunkedXHTML.php";

$formatclass = "TestChunkedXHTML";
Expand All @@ -26,6 +25,11 @@ $extra = array(
);

$test = new TestRender($formatclass, $opts, $extra);

if (Index::requireIndexing() && !file_exists($opts["output_dir"])) {
mkdir($opts["output_dir"], 0755);
}

$test->run();
?>

Expand All @@ -42,73 +46,40 @@ Content:
<h2 class="title">Class synopsis</h2>

<div class="classsynopsis">
<div class="ooclass"></div>
<span class="ooclass"><strong class="classname"></strong></span>

<div class="classsynopsisinfo">
<span class="ooclass">
<strong class="classname">SplStack</strong>
<span class="modifier">class</span> <strong class="classname">SplStack</strong>
</span>

<span class="ooclass">
<span class="modifier">extends</span>
<strong class="classname">SplDoublyLinkedList</strong>
</span>

<span class="oointerface">implements
<span class="interfacename"><strong class="interfacename">Iterator</strong></span>
</span>

<span class="oointerface">,
<span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>
<strong class="classname">SplDoublyLinkedList</strong>
</span>

<span class="oointerface">,
<span class="interfacename"><strong class="interfacename">Countable</strong></span>
</span>
{</div>
<span class="oointerface"><span class="modifier">implements</span>
<strong class="interfacename">Iterator</strong></span><span class="oointerface">, <strong class="interfacename">ArrayAccess</strong></span><span class="oointerface">, <strong class="interfacename">Countable</strong></span> {</div>

<div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
<div class="constructorsynopsis dc-description">
<span class="methodname"><strong>__construct</strong></span>
( <span class="methodparam">void</span>
)</div>
<span class="methodname"><strong>__construct</strong></span>()</div>

<div class="methodsynopsis dc-description">
<span class="type">void</span> <span class="methodname"><strong>setIteratorMode</strong></span>
( <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
)</div>
<div class="methodsynopsis dc-description"><span class="methodname"><strong>setIteratorMode</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>): <span class="type"><span class="type void">void</span></span></div>


<div class="classsynopsisinfo classsynopsisinfo_comment">/* Inherited methods */</div>
<div class="methodsynopsis dc-description">
<span class="type">mixed</span> <span class="methodname"><strong>SplDoublyLinkedList::bottom</strong></span>
( <span class="methodparam">void</span>
)</div>

<div class="methodsynopsis dc-description">
<span class="type">int</span> <span class="methodname"><strong>SplDoublyLinkedList::count</strong></span>
( <span class="methodparam">void</span>
)</div>

<div class="methodsynopsis dc-description">
<span class="type">mixed</span> <span class="methodname"><strong>SplDoublyLinkedList::current</strong></span>
( <span class="methodparam">void</span>
)</div>

<div class="methodsynopsis dc-description">
<span class="type">int</span> <span class="methodname"><strong>SplDoublyLinkedList::getIteratorMode</strong></span>
( <span class="methodparam">void</span>
)</div>

<div class="methodsynopsis dc-description">
<span class="type">bool</span> <span class="methodname"><strong>SplDoublyLinkedList::offsetExists</strong></span>
( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>
)</div>

<div class="methodsynopsis dc-description">
<span class="type">mixed</span> <span class="methodname"><strong>SplDoublyLinkedList::offsetGet</strong></span>
( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>
)</div>
<div class="methodsynopsis dc-description"><span class="methodname"><strong>SplDoublyLinkedList::bottom</strong></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

<div class="methodsynopsis dc-description"><span class="methodname"><strong>SplDoublyLinkedList::count</strong></span>(): <span class="type">int</span></div>

<div class="methodsynopsis dc-description"><span class="methodname"><strong>SplDoublyLinkedList::current</strong></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

<div class="methodsynopsis dc-description"><span class="methodname"><strong>SplDoublyLinkedList::getIteratorMode</strong></span>(): <span class="type">int</span></div>

<div class="methodsynopsis dc-description"><span class="methodname"><strong>SplDoublyLinkedList::offsetExists</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>): <span class="type">bool</span></div>

<div class="methodsynopsis dc-description"><span class="methodname"><strong>SplDoublyLinkedList::offsetGet</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

}</div>

Expand Down
6 changes: 5 additions & 1 deletion tests/php/faq001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Testing a simple FAQ
namespace phpdotnet\phd;

require_once __DIR__ . "/../setup.php";
require_once __DIR__ . "/../TestRender.php";
require_once __DIR__ . "/TestChunkedXHTML.php";

$formatclass = "TestChunkedXHTML";
Expand All @@ -25,6 +24,11 @@ $extra = array(
);

$render = new TestRender($formatclass, $opts, $extra);

if (Index::requireIndexing() && !file_exists($opts["output_dir"])) {
mkdir($opts["output_dir"], 0755);
}

$render->run();
?>
--EXPECT--
Expand Down
27 changes: 16 additions & 11 deletions tests/setup.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<?php
namespace phpdotnet\phd;

function autoload($name) {
$file = __DIR__ . "/../" . str_replace(array('\\', '_'), '/', $name) . '.php';
if (!$fp = fopen($file,'r', true)) {
throw new \Exception('Cannot find file for ' . $name . ': ' . $file);
}
fclose($fp);
require $file;
define("__PHDDIR__", __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR);
define("__INSTALLDIR__", "@php_dir@" == "@"."php_dir@" ? dirname(dirname(__DIR__)) : "@php_dir@");

}
spl_autoload_register(__NAMESPACE__ . '\\autoload');
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";

require_once __DIR__ . "/../phpdotnet/phd/functions.php";
require_once __DIR__ . "/../phpdotnet/phd/Config.php";
spl_autoload_register(["phpdotnet\\phd\\Autoloader", "autoload"]);

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',
"package_dirs" => [__PHDDIR__, __INSTALLDIR__],
]);

/*
* vim600: sw=4 ts=4 syntax=php et
Expand Down
Loading