8000 [8.x] Allows to clear translated parsed keys (#39490) · laravel/framework@cb46639 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb46639

Browse files
[8.x] Allows to clear translated parsed keys (#39490)
* Allows to clear translated parsed keys * Update NamespacedItemResolver.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 5539cf2 commit cb46639

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Illuminate/Support/NamespacedItemResolver.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,14 @@ public function setParsedKey($key, $parsed)
9999
{
100100
$this->parsed[$key] = $parsed;
101101
}
102+
103+
/**
104+
* Flush the cache of parsed keys.
105+
*
106+
* @return void
107+
*/
108+
public function flushParsedKeys()
109+
{
110+
$this->parsed = [];
111+
}
102112
}

tests/Support/SupportNamespacedItemResolverTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,17 @@ public function testParsedItemsAreCached()
2626

2727
$this->assertEquals(['foo'], $r->parseKey('foo.bar'));
2828
}
29+
30+
public function testParsedItemsMayBeFlushed()
31+
{
32+
$r = $this->getMockBuilder(NamespacedItemResolver::class)->onlyMethods(['parseBasicSegments', 'parseNamespacedSegments'])->getMock();
33+
$r->expects($this->once())->method('parseBasicSegments')->will(
34+
$this->returnValue(['bar'])
35+
);
36+
37+
$r->setParsedKey('foo.bar', ['foo']);
38+
$r->flushParsedKeys();
39+
40+
$this->assertEquals(['bar'], $r->parseKey('foo.bar'));
41+
}
2942
}

0 commit comments

Comments
 (0)
0