Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit52c42e7

Browse files
committed
Added more tests for the new feature
1 parent21bddea commit52c42e7

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

‎src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ public function testLintCorrectFile()
4040
$this->assertContains('OK',trim($tester->getDisplay()));
4141
}
4242

43+
/**
44+
* @dataProvider provideStrictFilenames
45+
*/
46+
publicfunctiontestStrictFilenames($requireStrictFileNames,$fileNamePattern,$targetLanguage,$mustFail)
47+
{
48+
$tester =$this->createCommandTester($requireStrictFileNames);
49+
$filename =$this->createFile('note',$targetLanguage,$fileNamePattern);
50+
51+
$tester->execute(
52+
array('filename' =>$filename),
53+
array('verbosity' => OutputInterface::VERBOSITY_VERBOSE,'decorated' =>false)
54+
);
55+
56+
$this->assertEquals($mustFail ?1 :0,$tester->getStatusCode());
57+
$this->assertContains($mustFail ?'[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.' :'[OK] All 1 XLIFF files contain valid syntax.',$tester->getDisplay());
58+
}
59+
4360
publicfunctiontestLintIncorrectXmlSyntax()
4461
{
4562
$tester =$this->createCommandTester();
@@ -102,7 +119,7 @@ public function testGetHelp()
102119
/**
103120
* @return string Path to the new file
104121
*/
105-
privatefunctioncreateFile($sourceContent ='note',$targetLanguage ='en')
122+
privatefunctioncreateFile($sourceContent ='note',$targetLanguage ='en',$fileNamePattern ='messages.%locale%.xlf')
106123
{
107124
$xliffContent =<<<XLIFF
108125
<?xml version="1.0"?>
@@ -118,7 +135,7 @@ private function createFile($sourceContent = 'note', $targetLanguage = 'en')
118135
</xliff>
119136
XLIFF;
120137

121-
$filename =sprintf('%s/translation-xliff-lint-test/messages.en.xlf',sys_get_temp_dir());
138+
$filename =sprintf('%s/translation-xliff-lint-test/%s',sys_get_temp_dir(),str_replace('%locale%','en',$fileNamePattern));
122139
file_put_contents($filename,$xliffContent);
123140

124141
$this->files[] =$filename;
@@ -129,11 +146,11 @@ private function createFile($sourceContent = 'note', $targetLanguage = 'en')
129146
/**
130147
* @return CommandTester
131148
*/
132-
privatefunctioncreateCommandTester($application =null)
149+
privatefunctioncreateCommandTester($requireStrictFileNames =true,$application =null)
133150
{
134151
if (!$application) {
135152
$application =newApplication();
136-
$application->add(newXliffLintCommand());
153+
$application->add(newXliffLintCommand(null,null,null,$requireStrictFileNames));
137154
}
138155

139156
$command =$application->find('lint:xliff');
@@ -160,4 +177,16 @@ protected function tearDown()
160177
}
161178
rmdir(sys_get_temp_dir().'/translation-xliff-lint-test');
162179
}
180+
181+
publicfunctionprovideStrictFilenames()
182+
{
183+
yieldarray(false,'messages.%locale%.xlf','en',false);
184+
yieldarray(false,'messages.%locale%.xlf','es',true);
185+
yieldarray(false,'%locale%.messages.xlf','en',false);
186+
yieldarray(false,'%locale%.messages.xlf','es',true);
187+
yieldarray(true,'messages.%locale%.xlf','en',false);
188+
yieldarray(true,'messages.%locale%.xlf','es',true);
189+
yieldarray(true,'%locale%.messages.xlf','en',true);
190+
yieldarray(true,'%locale%.messages.xlf','es',true);
191+
}
163192
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp