-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example indexing and rendering test
- Loading branch information
haszi
committed
Jun 4, 2024
1 parent
195745e
commit 20c580c
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<chapter xml:id="example-numbering"> | ||
<section> | ||
<example> | ||
<title>- 1. example without an xml:id</title> | ||
</example> | ||
</section> | ||
|
||
<section> | ||
<example> | ||
<title>- 2. example without an xml:id</title> | ||
</example> | ||
</section> | ||
|
||
<section> | ||
<example xml:id="third-example-id"> | ||
<title>- 3. example with an xml:id</title> | ||
</example> | ||
</section> | ||
|
||
<section> | ||
<example> | ||
<title>- 4. example without an xml:id</title> | ||
</example> | ||
</section> | ||
|
||
<section> | ||
<example> | ||
<title>- 5. example without an xml:id</title> | ||
</example> | ||
</section> | ||
</chapter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--TEST-- | ||
Example numbering 001 - indexing and rendering examples with and without an xml:id | ||
--FILE-- | ||
<?php | ||
namespace phpdotnet\phd; | ||
|
||
require_once __DIR__ . "/setup.php"; | ||
|
||
$xml_file = __DIR__ . "/data/example_numbering_001.xml"; | ||
|
||
Config::init([ | ||
"force_index" => true, | ||
"xml_file" => $xml_file, | ||
]); | ||
|
||
$indexRepository = new IndexRepository(new \SQLite3(":memory:")); | ||
$indexRepository->init(); | ||
Config::set_indexcache($indexRepository); | ||
|
||
$index = new TestIndex($indexRepository); | ||
|
||
$render = new TestRender(new Reader, new Config, null, $index); | ||
|
||
$render->run(); | ||
|
||
$indexes = array_keys($index->getNfo()); | ||
|
||
echo "Indexes stored:\n"; | ||
|
||
var_dump($indexes); | ||
|
||
$format = new TestGenericChunkedXHTML; | ||
|
||
$render = new TestRender(new Reader, new Config, $format); | ||
|
||
$render->run(); | ||
|
||
?> | ||
--EXPECT-- | ||
Indexes stored: | ||
array(6) { | ||
[0]=> | ||
string(17) "example-numbering" | ||
[1]=> | ||
string(9) "example-1" | ||
[2]=> | ||
string(9) "example-2" | ||
[3]=> | ||
string(16) "third-example-id" | ||
[4]=> | ||
string(9) "example-4" | ||
[5]=> | ||
string(9) "example-5" | ||
} | ||
Filename: example-numbering.html | ||
Content: | ||
<div id="example-numbering" class="chapter"> | ||
<div class="section"> | ||
<div class="example" id="example-1"> | ||
<p><strong>Example #1 - 1. example without an xml:id</strong></p> | ||
</div> | ||
</div> | ||
|
||
<div class="section"> | ||
<div class="example" id="example-2"> | ||
<p><strong>Example #2 - 2. example without an xml:id</strong></p> | ||
</div> | ||
</div> | ||
|
||
<div class="section"> | ||
<div class="example" id="third-example-id"> | ||
<p><strong>Example #3 - 3. example with an xml:id</strong></p> | ||
</div> | ||
</div> | ||
|
||
<div class="section"> | ||
<div class="example" id="example-4"> | ||
<p><strong>Example #4 - 4. example without an xml:id</strong></p> | ||
</div> | ||
</div> | ||
|
||
<div class="section"> | ||
<div class="example" id="example-5"> | ||
<p><strong>Example #5 - 5. example without an xml:id</strong></p> | ||
</div> | ||
</div> | ||
</div> |