-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add failed test for logger usage in directive
- Loading branch information
Showing
6 changed files
with
91 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
47 changes: 47 additions & 0 deletions
47
packages/guides-restructured-text/src/RestructuredText/Directives/TestLoggerDirective.php
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Guides\RestructuredText\Directives; | ||
|
||
use phpDocumentor\Guides\Nodes\CollectionNode; | ||
use phpDocumentor\Guides\Nodes\Node; | ||
use phpDocumentor\Guides\RestructuredText\Nodes\ContainerNode; | ||
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext; | ||
use phpDocumentor\Guides\RestructuredText\Parser\Directive; | ||
use phpDocumentor\Guides\RestructuredText\Parser\Productions\Rule; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Divs a sub document in a div with a given class or set of classes. | ||
* | ||
* @link https://docutils.sourceforge.io/docs/ref/rst/directives.html#container | ||
*/ | ||
class TestLoggerDirective extends SubDirective | ||
{ | ||
public function __construct( | ||
protected Rule $startingRule, | ||
private readonly LoggerInterface $logger, | ||
) { | ||
parent::__construct($startingRule); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'testlogger'; | ||
} | ||
|
||
/** {@inheritDoc} | ||
* | ||
* @param Directive $directive | ||
*/ | ||
protected function processSub( | ||
BlockContext $blockContext, | ||
CollectionNode $collectionNode, | ||
Directive $directive, | ||
): Node|null { | ||
$this->logger->warning('Test logging in directives', $blockContext->getLoggerInformation()); | ||
|
||
return (new ContainerNode($collectionNode->getChildren()))->withOptions(['class' => $directive->getData()]); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/Integration/tests/directives/directive-with-warning/expected/index.html
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,10 @@ | ||
<!-- content start --> | ||
<div class="section" id="directive-tests"> | ||
<h1>Directive tests</h1> | ||
|
||
<p>This is only displayed in HTML.</p> | ||
|
||
<p>This is only displayed in both HTML and Latex.</p> | ||
</div> | ||
|
||
<!-- content end --> |
20 changes: 20 additions & 0 deletions
20
tests/Integration/tests/directives/directive-with-warning/expected/index.tex
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,20 @@ | ||
\documentclass[11pt]{report} | ||
\usepackage[utf8]{inputenc} | ||
\usepackage[T1]{fontenc} | ||
\usepackage[french]{babel} | ||
\usepackage{cite} | ||
\usepackage{amssymb} | ||
\usepackage{amsmath} | ||
\usepackage{mathrsfs} | ||
\usepackage{graphicx} | ||
\usepackage{hyperref} | ||
\usepackage{listings} | ||
\begin{document} | ||
\label{} | ||
\section{Directive tests} | ||
|
||
|
||
This is only displayed in Latex. | ||
This is only displayed in both HTML and Latex. | ||
|
||
\end{document} |
8 changes: 8 additions & 0 deletions
8
tests/Integration/tests/directives/directive-with-warning/input/guides.xml
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<guides xmlns="https://www.phpdoc.org/guides" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd"> | ||
<output-format>tex</output-format> | ||
<output-format>interlink</output-format> | ||
<output-format>html</output-format> | ||
</guides> |
4 changes: 4 additions & 0 deletions
4
tests/Integration/tests/directives/directive-with-warning/input/index.rst
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,4 @@ | ||
Directive tests | ||
=============== | ||
|
||
.. testlogger:: |