Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ run-tests.php
**/tests/**/*.diff
**/tests/**/*.out*
**/tests/**/*.php
!tests/helpers.php
**/tests/**/*.exp
**/tests/**/*.log
**/tests/**/*.sh
2 changes: 1 addition & 1 deletion phpdotnet/phd/Package/PHP/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function header($id) {
"up" => $up,
"prev" => $prev,
"next" => $next,
"alternatives" => $this->cchunk["alternatives"],
"alternatives" => $this->cchunk["alternatives"] ?? [],
"source" => $this->sourceInfo($id),
);
$history = $this->history ?? [];
Expand Down
16 changes: 5 additions & 11 deletions tests/GH-225.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ all
<?php
namespace phpdotnet\phd;

if (!\file_exists(__DIR__ . "/../output/")) {
\mkdir(__DIR__ . "/../output/", 0777, true);
}
require_once __DIR__ . "/helpers.php";
ensureOutputFolder();

if (\file_exists(__DIR__ . "/../phd.config.php")) {
\unlink(__DIR__ . "/../phd.config.php");
Expand All @@ -27,14 +26,9 @@ require_once __DIR__ . "/../render.php";
--CLEAN--
<?php
\unlink(__DIR__ . "/../phd.config.php");
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(__DIR__ . "/../output/", \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $file) {
$file->isDir() ? \rmdir($file->getPathname()) : \unlink($file->getPathname());
}
\rmdir(__DIR__ . "/../output/");

require_once __DIR__ . "/helpers.php";
\phpdotnet\phd\removeOutputFolder();
?>
--EXPECTF--
%s[%d:%d:%d - Heads up ]%s Loaded config from existing file
26 changes: 26 additions & 0 deletions tests/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace phpdotnet\phd;

function ensureOutputFolder(): void
{
if (!\file_exists(\dirname(__DIR__) . "/output/")) {
\mkdir(\dirname(__DIR__) . "/output/", 0777, true);
}
}

function removeOutputFolder(): void
{
$folder = \dirname(__DIR__) . "/output/";
if (!\file_exists($folder)) {
return;
}

$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($folder, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $file) {
$file->isDir() ? \rmdir($file->getPathname()) : \unlink($file->getPathname());
}
\rmdir($folder);
}
8 changes: 8 additions & 0 deletions tests/options/default_handler_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Default options handler 007 - Save config (short option) and quit (short option)
--ARGS--
--docbook tests/options/default_handler_007.phpt -S -Q
--CONFLICTS--
all
--SKIPIF--
<?php
if (file_exists(__DIR__ . "/../../phd.config.php")) {
Expand All @@ -12,11 +14,17 @@ if (file_exists(__DIR__ . "/../../phd.config.php")) {
<?php
namespace phpdotnet\phd;

require_once __DIR__ . "/../helpers.php";
ensureOutputFolder();

require_once __DIR__ . "/../../render.php";
?>
--CLEAN--
<?php
unlink(__DIR__ . "/../../phd.config.php");

require_once __DIR__ . "/../helpers.php";
\phpdotnet\phd\removeOutputFolder();
?>
--EXPECTF--
%s[%d:%d:%d - Heads up ]%s Writing the config file
6 changes: 6 additions & 0 deletions tests/options/default_handler_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ if (file_exists(__DIR__ . "/../../phd.config.php")) {
<?php
namespace phpdotnet\phd;

require_once __DIR__ . "/../helpers.php";
ensureOutputFolder();

require_once __DIR__ . "/../../render.php";
?>
--CLEAN--
<?php
unlink(__DIR__ . "/../../phd.config.php");

require_once __DIR__ . "/../helpers.php";
\phpdotnet\phd\removeOutputFolder();
?>
--EXPECTF--
%s[%d:%d:%d - Heads up ]%s Writing the config file
4 changes: 4 additions & 0 deletions tests/render/data/sources.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<sources>
<file id="index" lang="en" path="index.xml"/>
</sources>
4 changes: 4 additions & 0 deletions tests/render/data/version.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<versions>
<function name="strlen" from="PHP 4, PHP 5, PHP 7, PHP 8"/>
</versions>
9 changes: 9 additions & 0 deletions tests/render/en/entities/entities.acronyms.ent
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<entities xmlns = "http://docbook.org/ns/docbook"
xmlns:xlink = "http://www.w3.org/1999/xlink"
translate = "yes">

<entity name="acronym.expansion.API">Application Programming Interface</entity>

</entities>
17 changes: 6 additions & 11 deletions tests/render/render_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
Render 001 - Smoke test render.php
--ARGS--
--memoryindex --forceindex --package PHP --format php --docbook tests/render/data/render_001.xml
--CONFLICTS--
all
--FILE--
<?php
namespace phpdotnet\phd;

if (!\file_exists(__DIR__ . "/../../output/")) {
\mkdir(__DIR__ . "/../../output/", 0777, true);
}
require_once __DIR__ . "/../helpers.php";
ensureOutputFolder();

require_once __DIR__ . "/../../render.php";
?>
--CLEAN--
<?php
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(__DIR__ . "/../../output/", \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $file) {
$file->isDir() ? \rmdir($file->getPathname()) : \unlink($file->getPathname());
}
\rmdir(__DIR__ . "/../../output/");
require_once __DIR__ . "/../helpers.php";
\phpdotnet\phd\removeOutputFolder();
?>
--EXPECTF--
%s[%d:%d:%d - Indexing ]%s Indexing...
Expand Down