Skip to content

Commit

Permalink
Merge pull request #10 from ts-navghane/remove-invalid-inis-from-zip
Browse files Browse the repository at this point in the history
Remove invalid ini files from zip
  • Loading branch information
escopecz authored Jul 10, 2023
2 parents e011439 + e83e221 commit 3b516de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Service/Transifex/TranslationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function getTranslations(TranslationDTO $translationDTO, LoggerInterface

sleep(2 ** $attempt);
} catch (InvalidFileException|RegexException $e) {
$this->filesystem->remove($filePath);
$this->outputErrors($logger, $filePath, $e->getMessage());
break;
}
Expand Down
24 changes: 22 additions & 2 deletions tests/Functional/Command/MauticLanguagePackerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ public static function provideExecutionData(): iterable
];
}

public function testPackageZipFolderStructure(): void
/**
* @dataProvider providePackageZipData
*/
public function testPackageZipFolderStructure(string $iniBody, bool $removeIniFile = false): void
{
$container = self::getContainer();
$transifexConfig = $container->get(ConfigInterface::class);
Expand Down Expand Up @@ -468,7 +471,7 @@ public function testPackageZipFolderStructure(): void
array_merge(['Content-Length' => ['498']], self::getCommonHeaders())
),
self::getMockResponse(
self::buildIniBody(),
self::buildIniBody($iniBody),
Request::METHOD_GET,
"https://rest.api.transifex.com/resource_translations_async_downloads/$uuid",
self::getCommonHeaders()
Expand Down Expand Up @@ -497,6 +500,12 @@ public function testPackageZipFolderStructure(): void
'af/config.json',
'af/config.php',
];

if ($removeIniFile) {
unset($expectedFolderStructure[1]);
$expectedFolderStructure = array_values($expectedFolderStructure);
}

$cnt = 0;

foreach ($packagesDirFinder as $file) {
Expand All @@ -515,6 +524,17 @@ public function testPackageZipFolderStructure(): void
Assert::assertSame(count($expectedFolderStructure), $cnt);
}

/**
* @return array<mixed>
*/
public static function providePackageZipData(): iterable
{
yield ['mautic.addon.notice.reloaded="%added% addons were added, %updated% updated, and %disabled% disabled."', false];

// invalid ini should get skip in the zip
yield ['mautic.addon.notice.reloaded="%added% addons were added, %updated% updated, and %disabled% disabled.', true];
}

/**
* @return array<string, array<string>>
*/
Expand Down

0 comments on commit 3b516de

Please sign in to comment.