Skip to content

Commit bfb8cbe

Browse files
committed
Add test case for duplicate path filtering
1 parent c88a5da commit bfb8cbe

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,46 @@ public function testWriteMessagesForSpecificDomain()
140140
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
141141
}
142142

143+
public function testFilterDuplicateTransPaths()
144+
{
145+
$transPaths = [
146+
$this->translationDir.'/a/test/folder/with/a/subfolder',
147+
$this->translationDir.'/a/test/folder/',
148+
$this->translationDir.'/a/test/folder/with/a/subfolder/and/a/file.txt',
149+
$this->translationDir.'/a/different/test/folder',
150+
];
151+
152+
foreach ($transPaths as $transPath) {
153+
if (realpath($transPath)) {
154+
continue;
155+
}
156+
157+
if (preg_match('/\.[a-z]+$/', $transPath)) {
158+
if (!realpath(dirname($transPath))) {
159+
mkdir(dirname($transPath), 0777, true);
160+
}
161+
162+
touch($transPath);
163+
} else {
164+
mkdir($transPath, 0777, true);
165+
}
166+
}
167+
168+
$expectedPaths = [
169+
$this->translationDir.'/a/different/test/folder',
170+
$this->translationDir.'/a/test/folder',
171+
];
172+
173+
$command = $this->createMock(TranslationUpdateCommand::class);
174+
175+
$method = new \ReflectionMethod(TranslationUpdateCommand::class, 'filterDuplicateTransPaths');
176+
$method->setAccessible(true);
177+
178+
$filteredTransPaths = $method->invoke($command, $transPaths);
179+
180+
$this->assertEquals($expectedPaths, $filteredTransPaths);
181+
}
182+
143183
protected function setUp(): void
144184
{
145185
$this->fs = new Filesystem();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy