Skip to content

Commit e1903c6

Browse files
committed
Add regression test for trailing backslash in text role
1 parent ca3744b commit e1903c6

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

packages/guides-restructured-text/tests/unit/Parser/Productions/InlineRules/TextRoleRuleTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,31 @@ public function __construct(
148148
*/
149149
self::assertSame($expectedRawContent, $node->rawContent);
150150
}
151+
152+
public function testApplyReturnsNullOnTrailingBackslashWithoutRaisingWarning(): void
153+
{
154+
$input = ":role:`text\\";
155+
156+
$textRoleFactory = $this->createMock(TextRoleFactory::class);
157+
$textRoleFactory->expects(self::never())->method('getTextRole');
158+
159+
$lexer = new InlineLexer();
160+
$lexer->setInput($input);
161+
$lexer->moveNext();
162+
$lexer->moveNext();
163+
164+
$textRoleRule = new TextRoleRule();
165+
self::assertTrue($textRoleRule->applies($lexer));
166+
167+
$documentParserContext = new DocumentParserContext(
168+
self::createStub(ParserContext::class),
169+
$textRoleFactory,
170+
self::createStub(MarkupLanguageParser::class),
171+
);
172+
173+
self::assertNull($textRoleRule->apply(
174+
new BlockContext($documentParserContext, ''),
175+
$lexer,
176+
));
177+
}
151178
}

0 commit comments

Comments
 (0)