@@ -72,6 +72,52 @@ public function itAppliesFixesToTheOriginalSourceWhenEntitiesExpandBeforeTheViol
7272 }
7373 }
7474
75+ #[Test] // TODO: should be integration
76+ public function itHandlesEntitiesWithoutParseErrors (): void
77+ {
78+ $ xml = $ this ->xml (
79+ '<!DOCTYPE chapter SYSTEM "docbook.dtd">
80+ <chapter>
81+ <simpara>&link.superglobals; &php.ini; &</simpara>
82+ </chapter> '
83+ );
84+
85+ $ processor = $ this ->processor ([], new EntityPreprocessor ([
86+ 'link.superglobals ' => '' ,
87+ 'php.ini ' => '' ,
88+ ]));
89+
90+ $ report = $ this ->process ($ processor , $ xml );
91+
92+ self ::assertCount (
93+ 0 ,
94+ array_filter (
95+ $ report ->getViolations (),
96+ fn ($ v ) => $ v ->sniffCode === 'DocbookCS.Internal '
97+ )
98+ );
99+ }
100+
101+ #[Test] // TODO: should be integration
102+ public function itUsesCustomPreprocessor (): void
103+ {
104+ $ processor = $ this ->processor ([], new EntityPreprocessor ([
105+ 'custom.entity ' => '[X] ' ,
106+ ]));
107+
108+ $ xml = $ this ->xml ('<chapter><simpara>&custom.entity;</simpara></chapter> ' );
109+
110+ $ report = $ this ->process ($ processor , $ xml );
111+
112+ self ::assertCount (
113+ 0 ,
114+ array_filter (
115+ $ report ->getViolations (),
116+ fn ($ v ) => $ v ->sniffCode === 'DocbookCS.Internal '
117+ )
118+ );
119+ }
120+
75121 private function process (XmlFileProcessor $ processor , string $ content , string $ path = 'input.xml ' ): FileReport
76122 {
77123 return $ processor ->process (new File ($ path , $ content ))->fileReport ;
@@ -90,6 +136,14 @@ private function processFile(XmlFileProcessor $processor, string $path): FileRep
90136 return $ result ->fileReport ;
91137 }
92138
139+ private function xml (string $ body ): string
140+ {
141+ return <<<XML
142+ <?xml version="1.0" encoding="UTF-8"?>
143+ $ body
144+ XML ;
145+ }
146+
93147 /** @param list<SniffInterface> $sniffs */
94148 private function processor (array $ sniffs = [], ?EntityPreprocessor $ pre = null ): XmlFileProcessor
95149 {
0 commit comments