Skip to content

Commit 9976c80

Browse files
committed
Add more tests for some use cases
1 parent f66c273 commit 9976c80

22 files changed

Lines changed: 144 additions & 32 deletions

File tree

packages/guides-pages/src/Pages/DependencyInjection/PagesExtension.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@
2222
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
2323

2424
use function array_is_list;
25-
use function array_keys;
26-
use function array_map;
27-
use function array_values;
2825
use function dirname;
2926
use function is_array;
3027
use function ltrim;
31-
use function phpDocumentor\Guides\DependencyInjection\templateArray;
3228

3329
/**
3430
* Symfony DI extension for the guides-pages package.
@@ -119,7 +115,6 @@ public function prepend(ContainerBuilder $container): void
119115
}
120116

121117
$container->prependExtensionConfig('guides', [
122-
// 'templates' => templateArray(require dirname(__DIR__, 3) . '/resources/template/page/template.php'),
123118
'base_template_paths' => [
124119
dirname(__DIR__, 3) . '/resources/template/page',
125120
],

packages/guides-pages/src/Pages/Nodes/ContentTypeItemNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public function getSummary(): ParagraphNode|null
308308
{
309309
return $this->summary;
310310
}
311+
311312
/**
312313
* Parses a raw date string (expected format `Y-m-d`) into a
313314
* {@see DateTimeImmutable}, returning `null` for empty or non-conforming

packages/guides-pages/tests/unit/Pages/DependencyInjection/PagesExtensionTest.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,11 @@
1616
use PHPUnit\Framework\TestCase;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
1818

19-
use function array_filter;
2019
use function str_contains;
2120

2221
/** @covers \phpDocumentor\Guides\Pages\DependencyInjection\PagesExtension */
2322
final class PagesExtensionTest extends TestCase
2423
{
25-
public function testPrependRegistersPageTemplatesUnderGuidesExtension(): void
26-
{
27-
$container = new ContainerBuilder();
28-
$extension = new PagesExtension();
29-
30-
$extension->prepend($container);
31-
32-
$configs = $container->getExtensionConfig('guides');
33-
self::assertNotEmpty($configs, 'Expected at least one prepended guides config block');
34-
35-
// Collect all prepended templates across every config block
36-
$allTemplates = [];
37-
foreach ($configs as $block) {
38-
foreach ($block['templates'] ?? [] as $tpl) {
39-
$allTemplates[] = $tpl;
40-
}
41-
}
42-
43-
$pageTemplates = array_filter(
44-
$allTemplates,
45-
static fn (array $t): bool => ($t['format'] ?? '') === 'page',
46-
);
47-
48-
self::assertNotEmpty($pageTemplates, 'PagesExtension should register at least one "page" format template');
49-
}
50-
5124
public function testPrependRegistersBaseTemplatePath(): void
5225
{
5326
$container = new ContainerBuilder();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- content start -->
2+
<div class="section" id="admonitions">
3+
<h1>Admonitions</h1>
4+
<div class="admonition note">
5+
<p>This is a note.</p>
6+
</div>
7+
<div class="admonition warning">
8+
<p>This is a warning.</p>
9+
</div>
10+
<div class="admonition tip">
11+
<p>This is a tip.</p>
12+
</div>
13+
</div>
14+
<!-- content end -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<guides xmlns="https://www.phpdoc.org/guides"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd"
5+
>
6+
<extension class="phpDocumentor\Guides\Pages\DependencyInjection\PagesExtension"
7+
source-directory="pages"
8+
/>
9+
</guides>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Index
2+
=====
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
===========
2+
Admonitions
3+
===========
4+
5+
.. note::
6+
7+
This is a note.
8+
9+
.. warning::
10+
11+
This is a warning.
12+
13+
.. tip::
14+
15+
This is a tip.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- content start -->
2+
<div class="section" id="image">
3+
<h1>Image</h1>
4+
<img
5+
src="/hero.svg"
6+
width="200" alt="Hero illustration" />
7+
8+
</div>
9+
<!-- content end -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<guides xmlns="https://www.phpdoc.org/guides"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd"
5+
>
6+
<extension class="phpDocumentor\Guides\Pages\DependencyInjection\PagesExtension"
7+
source-directory="pages"
8+
/>
9+
</guides>

0 commit comments

Comments
 (0)