Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3fdcbca

Browse filesBrowse files
committed
Add test case for duplicate path filtering
1 parent bfcb735 commit 3fdcbca
Copy full SHA for 3fdcbca

File tree

1 file changed

+40
-0
lines changed
Filter options

1 file changed

+40
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+40Lines 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+
$expectedPaths = [
153+
$this->translationDir.'/a/different/test/folder',
154+
$this->translationDir.'/a/test/folder',
155+
];
156+
157+
foreach ($transPaths as $transPath) {
158+
if (realpath($transPath)) {
159+
continue;
160+
}
161+
162+
if (preg_match('/\.[a-z]+$/', $transPath)) {
163+
if (!realpath(\dirname($transPath))) {
164+
mkdir(\dirname($transPath), 0777, true);
165+
}
166+
167+
touch($transPath);
168+
} else {
169+
mkdir($transPath, 0777, true);
170+
}
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.