File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
packages/guides-restructured-text
src/RestructuredText/TextRoles Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -53,16 +53,17 @@ public function replaceTextRole(TextRole $newTextRole): void
53
53
54
54
public function getTextRole (string $ name , string |null $ domain = null ): TextRole
55
55
{
56
- if ($ name === 'default ' ) {
56
+ $ normalizedName = strtolower ($ name );
57
+ if ($ normalizedName === 'default ' ) {
57
58
return $ this ->defaultTextRole ;
58
59
}
59
60
60
61
if ($ domain === null ) {
61
- return $ this ->findTextRole ($ this ->textRoles , $ name );
62
+ return $ this ->findTextRole ($ this ->textRoles , $ normalizedName );
62
63
}
63
64
64
65
if (isset ($ this ->domains [$ domain ])) {
65
- return $ this ->findTextRole ($ this ->domains [$ domain ], $ name );
66
+ return $ this ->findTextRole ($ this ->domains [$ domain ], $ normalizedName );
66
67
}
67
68
68
69
return $ this ->genericTextRole ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public function setUp(): void
26
26
{
27
27
$ this ->logger = new Logger ('test ' );
28
28
$ this ->defaultTextRoleFactory = new DefaultTextRoleFactory (
29
- new GenericTextRole (self :: createMock (SettingsManager::class)),
29
+ new GenericTextRole ($ this -> createMock (SettingsManager::class)),
30
30
new LiteralTextRole (),
31
31
[],
32
32
[],
@@ -45,4 +45,11 @@ public function testRegisteredTextRoleIsReturned(): void
45
45
$ textRole = $ this ->defaultTextRoleFactory ->getTextRole ('abbreviation ' );
46
46
self ::assertInstanceOf (AbbreviationTextRole::class, $ textRole );
47
47
}
48
+
49
+ public function testRegisteredTextRoleIsCaseInSensitive (): void
50
+ {
51
+ $ this ->defaultTextRoleFactory ->registerTextRole (new AbbreviationTextRole ($ this ->logger ));
52
+ $ textRole = $ this ->defaultTextRoleFactory ->getTextRole ('ABbreviation ' );
53
+ self ::assertInstanceOf (AbbreviationTextRole::class, $ textRole );
54
+ }
48
55
}
You can’t perform that action at this time.
0 commit comments