composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -40,6 +40,38 @@ class XliffLintCommandTest extends TestCase
$this->assertContains('OK', trim($tester->getDisplay()));
}
public function testLintCorrectFiles()
{
$tester = $this->createCommandTester();
$filename1 = $this->createFile();
$filename2 = $this->createFile();
$tester->execute(
array('filename' => array($filename1, $filename2)),
array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)
);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('OK', trim($tester->getDisplay()));
}
/**
* @dataProvider provideStrictFilenames
*/
public function testStrictFilenames($requireStrictFileNames, $fileNamePattern, $targetLanguage, $mustFail)
{
$tester = $this->createCommandTester($requireStrictFileNames);
$filename = $this->createFile('note', $targetLanguage, $fileNamePattern);
$tester->execute(
array('filename' => $filename),
array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)
);
$this->assertEquals($mustFail ? 1 : 0, $tester->getStatusCode());
$this->assertContains($mustFail ? '[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.' : '[OK] All 1 XLIFF files contain valid syntax.', $tester->getDisplay());
}
public function testLintIncorrectXmlSyntax()
{
$tester = $this->createCommandTester();
@@ -59,7 +91,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(array('filename' => $filename), array('decorated' => false));
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
$this->assertContains('There is a mismatch between the file extension ("en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
$this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
}
/**
@@ -102,7 +134,7 @@ EOF;
/**
* @return string Path to the new file
*/
private function createFile($sourceContent = 'note', $targetLanguage = 'en')
private function createFile($sourceContent = 'note', $targetLanguage = 'en', $fileNamePattern = 'messages.%locale%.xlf')
{
$xliffContent = <<<XLIFF
<?xml version="1.0"?>
@@ -118,7 +150,7 @@ EOF;
</xliff>
XLIFF;
$filename = sprintf('%s/translation-xliff-lint-test/messages.en.xlf', sys_get_temp_dir());
$filename = sprintf('%s/translation-xliff-lint-test/%s', sys_get_temp_dir(), str_replace('%locale%', 'en', $fileNamePattern));
file_put_contents($filename, $xliffContent);
$this->files[] = $filename;
@@ -129,11 +161,11 @@ XLIFF;
/**
* @return CommandTester
*/
private function createCommandTester($application = null)
private function createCommandTester($requireStrictFileNames = true, $application = null)
{
if (!$application) {
$application = new Application();
$application->add(new XliffLintCommand());
$application->add(new XliffLintCommand(null, null, null, $requireStrictFileNames));
}
$command = $application->find('lint:xliff');
@@ -160,4 +192,16 @@ XLIFF;
}
rmdir(sys_get_temp_dir().'/translation-xliff-lint-test');
}
public function provideStrictFilenames()
{
yield array(false, 'messages.%locale%.xlf', 'en', false);
yield array(false, 'messages.%locale%.xlf', 'es', true);
yield array(false, '%locale%.messages.xlf', 'en', false);
yield array(false, '%locale%.messages.xlf', 'es', true);
yield array(true, 'messages.%locale%.xlf', 'en', false);
yield array(true, 'messages.%locale%.xlf', 'es', true);
yield array(true, '%locale%.messages.xlf', 'en', true);
yield array(true, '%locale%.messages.xlf', 'es', true);
}
}