From 6151894060728eb18b1bc5c385b16d581f02c7d4 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 25 Nov 2020 20:32:46 +0800 Subject: [PATCH 1/7] Remove test/_support directory --- tests/_support/CIUnitTestCase.php | 8 --- tests/_support/Language/MockLanguage.php | 61 ---------------- .../_support/Language/SecondMockLanguage.php | 27 ------- tests/_support/Language/ab-CD/Allin.php | 8 --- tests/_support/Language/ab/Allin.php | 8 --- tests/_support/Language/en-ZZ/More.php | 6 -- tests/_support/Language/en/Allin.php | 8 --- tests/_support/Language/en/Core.php | 20 ------ tests/_support/Language/en/More.php | 7 -- tests/_support/Language/ru/Language.php | 5 -- tests/_support/MockCodeIgniter.php | 11 --- tests/_support/MockCommon.php | 37 ---------- tests/_support/Services.php | 70 ------------------- tests/_support/_bootstrap.php | 32 --------- 14 files changed, 308 deletions(-) delete mode 100644 tests/_support/CIUnitTestCase.php delete mode 100644 tests/_support/Language/MockLanguage.php delete mode 100644 tests/_support/Language/SecondMockLanguage.php delete mode 100644 tests/_support/Language/ab-CD/Allin.php delete mode 100644 tests/_support/Language/ab/Allin.php delete mode 100644 tests/_support/Language/en-ZZ/More.php delete mode 100644 tests/_support/Language/en/Allin.php delete mode 100644 tests/_support/Language/en/Core.php delete mode 100644 tests/_support/Language/en/More.php delete mode 100644 tests/_support/Language/ru/Language.php delete mode 100644 tests/_support/MockCodeIgniter.php delete mode 100644 tests/_support/MockCommon.php delete mode 100644 tests/_support/Services.php delete mode 100644 tests/_support/_bootstrap.php diff --git a/tests/_support/CIUnitTestCase.php b/tests/_support/CIUnitTestCase.php deleted file mode 100644 index b475b62e..00000000 --- a/tests/_support/CIUnitTestCase.php +++ /dev/null @@ -1,8 +0,0 @@ -language[$locale ?? $this->locale][$file] = $data; - - return $this; - } - - //-------------------------------------------------------------------- - - /** - * Provides an override that allows us to set custom - * data to be returned easily during testing. - * - * @param string $path - * - * @return array|mixed - */ - protected function requireFile(string $path): array - { - return $this->data ?? []; - } - - //-------------------------------------------------------------------- - - /** - * Arbitrarily turnoff internationalization support for testing - */ - public function disableIntlSupport() - { - $this->intlSupport = false; - } - -} diff --git a/tests/_support/Language/SecondMockLanguage.php b/tests/_support/Language/SecondMockLanguage.php deleted file mode 100644 index 71428854..00000000 --- a/tests/_support/Language/SecondMockLanguage.php +++ /dev/null @@ -1,27 +0,0 @@ -load($file, $locale, $return); - } - - //-------------------------------------------------------------------- - - /** - * Expose the loaded language files - */ - public function loaded(string $locale = 'en') - { - return $this->loadedFiles[$locale]; - } - -} diff --git a/tests/_support/Language/ab-CD/Allin.php b/tests/_support/Language/ab-CD/Allin.php deleted file mode 100644 index 3b153883..00000000 --- a/tests/_support/Language/ab-CD/Allin.php +++ /dev/null @@ -1,8 +0,0 @@ - 'Pyramid of Giza', - 'tre' => 'Colossus of Rhodes', - 'fiv' => 'Temple of Artemis', - 'sev' => 'Hanging Gardens of Babylon', -]; diff --git a/tests/_support/Language/ab/Allin.php b/tests/_support/Language/ab/Allin.php deleted file mode 100644 index 69120758..00000000 --- a/tests/_support/Language/ab/Allin.php +++ /dev/null @@ -1,8 +0,0 @@ - 'gluttony', - 'tre' => 'greed', - 'six' => 'envy', - 'sev' => 'pride', -]; diff --git a/tests/_support/Language/en-ZZ/More.php b/tests/_support/Language/en-ZZ/More.php deleted file mode 100644 index 66810205..00000000 --- a/tests/_support/Language/en-ZZ/More.php +++ /dev/null @@ -1,6 +0,0 @@ - 'These are not the droids you are looking for', - 'notaMoon' => "It's made of cheese", - 'wisdom' => 'There is no try', -]; diff --git a/tests/_support/Language/en/Allin.php b/tests/_support/Language/en/Allin.php deleted file mode 100644 index 6a10dcc7..00000000 --- a/tests/_support/Language/en/Allin.php +++ /dev/null @@ -1,8 +0,0 @@ - 'four calling birds', - 'fiv' => 'five golden rings', - 'six' => 'six geese a laying', - 'sev' => 'seven swans a swimming', -]; diff --git a/tests/_support/Language/en/Core.php b/tests/_support/Language/en/Core.php deleted file mode 100644 index b2fc4c18..00000000 --- a/tests/_support/Language/en/Core.php +++ /dev/null @@ -1,20 +0,0 @@ - '{0} extension could not be found.', - 'bazillion' => 'billions and billions', // adds a new setting -]; diff --git a/tests/_support/Language/en/More.php b/tests/_support/Language/en/More.php deleted file mode 100644 index 5b4eaea5..00000000 --- a/tests/_support/Language/en/More.php +++ /dev/null @@ -1,7 +0,0 @@ - 'These are not the droids you are looking for', - 'notaMoon' => "That's no moon... it's a space station", - 'cannotMove' => 'I have a very bad feeling about this', -]; diff --git a/tests/_support/Language/ru/Language.php b/tests/_support/Language/ru/Language.php deleted file mode 100644 index d6c6632b..00000000 --- a/tests/_support/Language/ru/Language.php +++ /dev/null @@ -1,5 +0,0 @@ - 'Whatever this would be, translated', -]; diff --git a/tests/_support/MockCodeIgniter.php b/tests/_support/MockCodeIgniter.php deleted file mode 100644 index 3e31d001..00000000 --- a/tests/_support/MockCodeIgniter.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Wed, 25 Nov 2020 22:33:49 +0800 Subject: [PATCH 2/7] Update composer.json --- composer.json | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 05a1ddb4..2567eea0 100644 --- a/composer.json +++ b/composer.json @@ -8,18 +8,35 @@ "php": ">=7.2", "ext-intl": "*" }, + "require-dev": { + "codeigniter4/codeigniter4": "dev-develop", + "phpunit/phpunit": "^8.5" + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, "autoload": { "psr-4": { - "Translations\\": "" + "CodeIgniter\\Language\\": "Language/" } }, + "autoload-dev": { + "psr-4": { + "CodeIgniter\\Language\\": "tests/Language/" + } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/codeigniter4/codeigniter4", + "canonical": true + } + ], "support": { "forum": "http://forum.codeigniter.com/", "source": "https://github.com/codeigniter4/translations", "slack": "https://codeigniterchat.slack.com" - }, - "require-dev": { - "codeigniter4/framework": "dev-master", - "phpunit/phpunit": "^7.0" } } From 7c6ec90681f83bc3f2bd13fc9e14c27cf9186214 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 26 Nov 2020 01:04:21 +0800 Subject: [PATCH 3/7] Update phpunit.xml --- phpunit.xml.dist | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0b5897ad..4dd38cd9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,30 @@ - + - - ./tests/system + + tests/Language + + + Language + + + - + From eda493511c954bca57d959eb05861f5d611e199e Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 26 Nov 2020 01:19:01 +0800 Subject: [PATCH 4/7] Refactor test case to allow individual locale testing --- .../Language/AbstractTranslationTestCase.php | 361 ++++++++++++++++++ tests/Language/AllLocalesTranslationTest.php | 19 + tests/Language/ArabicTranslationTest.php | 19 + tests/Language/BrazilianTranslationTest.php | 19 + tests/Language/CzechTranslationTest.php | 19 + tests/Language/DutchTranslationTest.php | 19 + tests/Language/FarsiTranslationTest.php | 19 + tests/Language/FrenchTranslationTest.php | 19 + tests/Language/GermanTranslationTest.php | 19 + tests/Language/IndonesianTranslationTest.php | 19 + tests/Language/ItalianTranslationTest.php | 19 + tests/Language/JapaneseTranslationTest.php | 19 + tests/Language/KoreanTranslationTest.php | 19 + tests/Language/LatvianTranslationTest.php | 19 + tests/Language/LithuanianTranslationTest.php | 19 + tests/Language/MalayalamTranslationTest.php | 19 + tests/Language/NorwegianTranslationTest.php | 19 + tests/Language/PolishTranslationTest.php | 19 + tests/Language/PortugueseTranslationTest.php | 19 + tests/Language/RussianTranslationTest.php | 19 + .../Language/SimpleChineseTranslationTest.php | 19 + tests/Language/SlovakTranslationTest.php | 19 + tests/Language/SpanishTranslationTest.php | 19 + .../TraditionalChineseTranslationTest.php | 19 + tests/Language/TurkishTranslationTest.php | 19 + tests/Language/UkrainianTranslationTest.php | 19 + tests/Language/VietnameseTranslationTest.php | 19 + tests/system/Language/TranslationsTest.php | 172 --------- 28 files changed, 855 insertions(+), 172 deletions(-) create mode 100644 tests/Language/AbstractTranslationTestCase.php create mode 100644 tests/Language/AllLocalesTranslationTest.php create mode 100644 tests/Language/ArabicTranslationTest.php create mode 100644 tests/Language/BrazilianTranslationTest.php create mode 100644 tests/Language/CzechTranslationTest.php create mode 100644 tests/Language/DutchTranslationTest.php create mode 100644 tests/Language/FarsiTranslationTest.php create mode 100644 tests/Language/FrenchTranslationTest.php create mode 100644 tests/Language/GermanTranslationTest.php create mode 100644 tests/Language/IndonesianTranslationTest.php create mode 100644 tests/Language/ItalianTranslationTest.php create mode 100644 tests/Language/JapaneseTranslationTest.php create mode 100644 tests/Language/KoreanTranslationTest.php create mode 100644 tests/Language/LatvianTranslationTest.php create mode 100644 tests/Language/LithuanianTranslationTest.php create mode 100644 tests/Language/MalayalamTranslationTest.php create mode 100644 tests/Language/NorwegianTranslationTest.php create mode 100644 tests/Language/PolishTranslationTest.php create mode 100644 tests/Language/PortugueseTranslationTest.php create mode 100644 tests/Language/RussianTranslationTest.php create mode 100644 tests/Language/SimpleChineseTranslationTest.php create mode 100644 tests/Language/SlovakTranslationTest.php create mode 100644 tests/Language/SpanishTranslationTest.php create mode 100644 tests/Language/TraditionalChineseTranslationTest.php create mode 100644 tests/Language/TurkishTranslationTest.php create mode 100644 tests/Language/UkrainianTranslationTest.php create mode 100644 tests/Language/VietnameseTranslationTest.php delete mode 100644 tests/system/Language/TranslationsTest.php diff --git a/tests/Language/AbstractTranslationTestCase.php b/tests/Language/AbstractTranslationTestCase.php new file mode 100644 index 00000000..4ec4f23e --- /dev/null +++ b/tests/Language/AbstractTranslationTestCase.php @@ -0,0 +1,361 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +use PHPUnit\Framework\TestCase; + +/** + * This abstract test class does the heavy testing of the sufficiency + * and precision of provided per-locale translations. + * + * New tests for new locales should extend this class and marked as "final". + * + * @internal + */ +abstract class AbstractTranslationTestCase extends TestCase +{ + /** + * Relative path to the main language folder in main repository. + * + * @var string + */ + private const MAIN_LANGUAGE_REPO = '/vendor/codeigniter4/codeigniter4/system/Language/en/'; + + /** + * Collection of all locale codes mapped from the + * individual locale translation test case. + * + * **NOTE: Do not include `AllLocalesTranslationTest` in + * this collection.** + * + * @var array + */ + public static $locales = [ + ArabicTranslationTest::class => 'ar', + CzechTranslationTest::class => 'cs', + GermanTranslationTest::class => 'de', + SpanishTranslationTest::class => 'es', + FarsiTranslationTest::class => 'fa', + FrenchTranslationTest::class => 'fr', + IndonesianTranslationTest::class => 'id', + ItalianTranslationTest::class => 'it', + JapaneseTranslationTest::class => 'ja', + KoreanTranslationTest::class => 'ko', + LithuanianTranslationTest::class => 'lt', + LatvianTranslationTest::class => 'lv', + MalayalamTranslationTest::class => 'ml', + DutchTranslationTest::class => 'nl', + NorwegianTranslationTest::class => 'no', + PolishTranslationTest::class => 'pl', + PortugueseTranslationTest::class => 'pt', + BrazilianTranslationTest::class => 'pt-BR', + RussianTranslationTest::class => 'ru', + SlovakTranslationTest::class => 'sk', + TurkishTranslationTest::class => 'tr', + UkrainianTranslationTest::class => 'uk', + VietnameseTranslationTest::class => 'vi', + SimpleChineseTranslationTest::class => 'zh-CN', + TraditionalChineseTranslationTest::class => 'zh-TW', + ]; + + //------------------------------------------------------------------------- + // TESTS + //------------------------------------------------------------------------- + + /** + * This tests that all language files configured in the main CI4 repository + * have a corresponding language file in the current locale. + * + * @dataProvider localesProvider + * + * @param string $locale + * + * @return void + */ + final public function testAllConfiguredLanguageFilesAreTranslated(string $locale): void + { + // These localisation variants are usually independent on their own and have no single + // parent locale to compare with so they are treated as if a parent locale + static $excludedLocales = [ + 'pt-BR', + 'sv-SE', + 'sv-FI', + 'zh-CN', + 'zh-TW', + ]; + + $filesNotTranslated = []; + + if (strlen($locale) === 2 || (strlen($locale) > 2 && in_array($locale, $excludedLocales, true))) + { + $filesNotTranslated = array_diff( + $this->expectedSets(), + $this->foundSets($locale) + ); + } + + sort($filesNotTranslated); + $count = count($filesNotTranslated); + + $this->assertEmpty($filesNotTranslated, sprintf( + 'Failed asserting that language %s "%s" in the main repository %s translated in "%s" locale.', + $count > 1 ? 'files' : 'file', + implode('", "', $filesNotTranslated), + $count > 1 ? 'are' : 'is', + $locale + )); + } + + /** + * This tests that all translated language files in the current locale have a + * corresponding language file in the main CI4 repository. + * + * @dataProvider localesProvider + * + * @param string $locale + * + * @return void + */ + final public function testAllTranslatedLanguageFilesAreConfigured(string $locale): void + { + $filesNotConfigured = array_diff( + $this->foundSets($locale), + $this->expectedSets() + ); + + sort($filesNotConfigured); + $count = count($filesNotConfigured); + + $this->assertEmpty($filesNotConfigured, sprintf( + 'Failed asserting that translated language %s "%s" in "%s" locale %s configured in the main repository.', + $count > 1 ? 'files' : 'file', + implode('", "', $filesNotConfigured), + $locale, + $count > 1 ? 'are' : 'is' + )); + } + + /** + * This tests that all language keys defined by a language file in the main CI4 + * repository have corresponding keys in the current locale. + * + * @dataProvider localesProvider + * + * @param string $locale + * + * @return void + */ + final public function testAllConfiguredLanguageKeysAreIncluded(string $locale): void + { + $availableSets = array_intersect($this->expectedSets(), $this->foundSets($locale)); + $keysNotIncluded = []; + + foreach ($availableSets as $file) + { + $missing = array_diff_key( + $this->loadFile($file), + $this->loadFile($file, $locale) + ); + + foreach (array_keys($missing) as $key) + { + $keysNotIncluded[] = substr($file, 0, -4) . '.' . $key; + } + } + + sort($keysNotIncluded); + $count = count($keysNotIncluded); + + $this->assertEmpty($keysNotIncluded, sprintf( + 'Failed asserting that the language %s "%s" in the main repository %s included for translation in "%s" locale.', + $count > 1 ? 'keys' : 'key', + implode('", "', $keysNotIncluded), + $count > 1 ? 'are' : 'is', + $locale + )); + } + + /** + * This tests that all included language keys in a language file for the current + * locale have corresponding keys in the main CI4 repository. + * + * @dataProvider localesProvider + * + * @param string $locale + * + * @return void + */ + final public function testAllIncludedLanguageKeysAreConfigured(string $locale): void + { + $availableSets = array_intersect($this->expectedSets(), $this->foundSets($locale)); + $keysNotConfigured = []; + + foreach ($availableSets as $file) + { + $extra = array_diff_key( + $this->loadFile($file, $locale), + $this->loadFile($file) + ); + + foreach (array_keys($extra) as $key) + { + $keysNotConfigured[] = substr($file, 0, -4) . '.' . $key; + } + } + + sort($keysNotConfigured); + $count = count($keysNotConfigured); + + $this->assertEmpty($keysNotConfigured, sprintf( + 'Failed asserting that the translated language %s "%s" in "%s" locale %s configured in the main repository.', + $count > 1 ? 'keys' : 'key', + implode('", "', $keysNotConfigured), + $locale, + $count > 1 ? 'are' : 'is' + )); + } + + final public function localesProvider(): iterable + { + helper('filesystem'); + $locale = self::$locales[static::class] ?? $this->translationKeys(); + + if (! is_array($locale)) + { + $locale = [$locale => [$locale]]; + } + + return $locale; + } + + final public function testAllLocalesHaveCorrespondingTestCaseInArray(): void + { + $untestedLocales = array_diff( + array_keys($this->translationKeys()), + array_values(self::$locales) + ); + + sort($untestedLocales); + $count = count($untestedLocales); + + $this->assertEmpty($untestedLocales, sprintf( + 'Failed asserting that %s "%s" %s corresponding test %s in %s::$locales array.', + $count > 1 ? 'locales' : 'locale', + implode('", "', $untestedLocales), + $count > 1 ? 'have' : 'has a', + $count > 1 ? 'cases' : 'case', + self::class + )); + } + + /** + * @dataProvider localeTestCaseProvider + * + * @param string $class + * + * @return void + */ + final public function testAllLocalesHaveCorrespondingTestCaseFiles(string $class): void + { + $this->assertTrue(class_exists($class, false), sprintf( + 'Failed asserting that test class "%s" is existing.', + $class + )); + } + + final public function localeTestCaseProvider(): iterable + { + $set = []; + + foreach (self::$locales as $class => $locale) + { + $set[$locale] = [$class]; + } + + return $set; + } + + //------------------------------------------------------------------------- + // UTILITIES + //------------------------------------------------------------------------- + + /** + * Get all the ISO 639-1 and 639-2 locale codes. + * + * @return array> + */ + final public function translationKeys(): array + { + $sets = []; + $dirs = directory_map(getcwd() . '/Language', 1); + + foreach ($dirs as $dir) + { + $dir = trim($dir, '\\/'); + $sets[$dir] = [$dir]; + } + + return $sets; + } + + final public function expectedSets(): array + { + static $expected; + + if (null === $expected) + { + $expected = $this->translationSets(); + } + + return $expected; + } + + final public function foundSets(string $locale): array + { + return $this->translationSets($locale); + } + + final public function loadFile(string $file, ?string $locale = null): array + { + $folder = $locale + ? getcwd() . "/Language/{$locale}/" + : getcwd() . self::MAIN_LANGUAGE_REPO; + + $file = $folder . $file; + + return require $file; + } + + /** + * Gets the set of language files for each location. + * + * @param string|null $locale + * + * @return array + */ + private function translationSets(?string $locale = null): array + { + $location = $locale + ? getcwd() . "/Language/{$locale}/" + : getcwd() . self::MAIN_LANGUAGE_REPO; + + $sets = []; + $files = directory_map($location, 1); + + foreach ($files as $file) + { + $sets[$file] = $file; + } + + return $sets; + } +} diff --git a/tests/Language/AllLocalesTranslationTest.php b/tests/Language/AllLocalesTranslationTest.php new file mode 100644 index 00000000..3c21f298 --- /dev/null +++ b/tests/Language/AllLocalesTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class AllLocalesTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/ArabicTranslationTest.php b/tests/Language/ArabicTranslationTest.php new file mode 100644 index 00000000..65b33a07 --- /dev/null +++ b/tests/Language/ArabicTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class ArabicTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/BrazilianTranslationTest.php b/tests/Language/BrazilianTranslationTest.php new file mode 100644 index 00000000..70bd4cbc --- /dev/null +++ b/tests/Language/BrazilianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class BrazilianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/CzechTranslationTest.php b/tests/Language/CzechTranslationTest.php new file mode 100644 index 00000000..a8531623 --- /dev/null +++ b/tests/Language/CzechTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class CzechTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/DutchTranslationTest.php b/tests/Language/DutchTranslationTest.php new file mode 100644 index 00000000..fe1f9486 --- /dev/null +++ b/tests/Language/DutchTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class DutchTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/FarsiTranslationTest.php b/tests/Language/FarsiTranslationTest.php new file mode 100644 index 00000000..eda7d02d --- /dev/null +++ b/tests/Language/FarsiTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class FarsiTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/FrenchTranslationTest.php b/tests/Language/FrenchTranslationTest.php new file mode 100644 index 00000000..7df3df25 --- /dev/null +++ b/tests/Language/FrenchTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class FrenchTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/GermanTranslationTest.php b/tests/Language/GermanTranslationTest.php new file mode 100644 index 00000000..72601fa5 --- /dev/null +++ b/tests/Language/GermanTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class GermanTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/IndonesianTranslationTest.php b/tests/Language/IndonesianTranslationTest.php new file mode 100644 index 00000000..d401d01e --- /dev/null +++ b/tests/Language/IndonesianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class IndonesianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/ItalianTranslationTest.php b/tests/Language/ItalianTranslationTest.php new file mode 100644 index 00000000..7f511ea9 --- /dev/null +++ b/tests/Language/ItalianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class ItalianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/JapaneseTranslationTest.php b/tests/Language/JapaneseTranslationTest.php new file mode 100644 index 00000000..952d8e08 --- /dev/null +++ b/tests/Language/JapaneseTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class JapaneseTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/KoreanTranslationTest.php b/tests/Language/KoreanTranslationTest.php new file mode 100644 index 00000000..79195c00 --- /dev/null +++ b/tests/Language/KoreanTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class KoreanTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/LatvianTranslationTest.php b/tests/Language/LatvianTranslationTest.php new file mode 100644 index 00000000..53e0d13f --- /dev/null +++ b/tests/Language/LatvianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class LatvianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/LithuanianTranslationTest.php b/tests/Language/LithuanianTranslationTest.php new file mode 100644 index 00000000..1c7868ee --- /dev/null +++ b/tests/Language/LithuanianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class LithuanianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/MalayalamTranslationTest.php b/tests/Language/MalayalamTranslationTest.php new file mode 100644 index 00000000..f8e340cd --- /dev/null +++ b/tests/Language/MalayalamTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class MalayalamTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/NorwegianTranslationTest.php b/tests/Language/NorwegianTranslationTest.php new file mode 100644 index 00000000..28e3417f --- /dev/null +++ b/tests/Language/NorwegianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class NorwegianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/PolishTranslationTest.php b/tests/Language/PolishTranslationTest.php new file mode 100644 index 00000000..8d7ca233 --- /dev/null +++ b/tests/Language/PolishTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class PolishTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/PortugueseTranslationTest.php b/tests/Language/PortugueseTranslationTest.php new file mode 100644 index 00000000..e7afecbc --- /dev/null +++ b/tests/Language/PortugueseTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class PortugueseTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/RussianTranslationTest.php b/tests/Language/RussianTranslationTest.php new file mode 100644 index 00000000..a67077f0 --- /dev/null +++ b/tests/Language/RussianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class RussianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/SimpleChineseTranslationTest.php b/tests/Language/SimpleChineseTranslationTest.php new file mode 100644 index 00000000..615c9f6b --- /dev/null +++ b/tests/Language/SimpleChineseTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class SimpleChineseTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/SlovakTranslationTest.php b/tests/Language/SlovakTranslationTest.php new file mode 100644 index 00000000..d4793ad4 --- /dev/null +++ b/tests/Language/SlovakTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class SlovakTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/SpanishTranslationTest.php b/tests/Language/SpanishTranslationTest.php new file mode 100644 index 00000000..4f64e8d1 --- /dev/null +++ b/tests/Language/SpanishTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class SpanishTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/TraditionalChineseTranslationTest.php b/tests/Language/TraditionalChineseTranslationTest.php new file mode 100644 index 00000000..48e7364a --- /dev/null +++ b/tests/Language/TraditionalChineseTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class TraditionalChineseTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/TurkishTranslationTest.php b/tests/Language/TurkishTranslationTest.php new file mode 100644 index 00000000..afdb751c --- /dev/null +++ b/tests/Language/TurkishTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class TurkishTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/UkrainianTranslationTest.php b/tests/Language/UkrainianTranslationTest.php new file mode 100644 index 00000000..a1ba3f26 --- /dev/null +++ b/tests/Language/UkrainianTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class UkrainianTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/Language/VietnameseTranslationTest.php b/tests/Language/VietnameseTranslationTest.php new file mode 100644 index 00000000..dac09103 --- /dev/null +++ b/tests/Language/VietnameseTranslationTest.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CodeIgniter\Language; + +/** + * @internal + */ +final class VietnameseTranslationTest extends AbstractTranslationTestCase +{ +} diff --git a/tests/system/Language/TranslationsTest.php b/tests/system/Language/TranslationsTest.php deleted file mode 100644 index 41d5d55f..00000000 --- a/tests/system/Language/TranslationsTest.php +++ /dev/null @@ -1,172 +0,0 @@ -expected = $this->expectedSets(); - } - - /** - * Identify all the locales in the translations repo. - * - * @return [][] - */ - public function translations() - { - $dir = getcwd() . '/Language/'; - $dh = opendir($dir); - $sets = []; - while (($file = readdir($dh)) !== false) - { - if (substr($file, 0, 1) != '.') - $sets[$file] = [$file]; - } - closedir($dh); - ksort($sets); - return $sets; - } - - /** - * For a given translation locale found, make sure that all of - * the translation sets (individual files) are there. - * This is relaxed for sublocales (eg fr-CA), which are only - * expected to provide variations for a parent locale. - * - * @dataProvider translations - */ - public function testMissingFiles($locale) - { - $diff = (strlen($locale) > 2) ? [] : array_diff($this->expected, $this->foundSets($locale)); - if (count($diff) > 0) - $this->fail($locale . ' is missing: ' . implode(' ', $diff)); - else - $this->assertTrue(true); - } - - /** - * For a given translation locale found, make sure that there - * are no extra (unneeded) translation sets provided. - * - * @dataProvider translations - */ - public function testExtraFiles($locale) - { - $diff = array_diff($this->foundSets($locale), $this->expected); - if (count($diff) > 0) - $this->fail($locale . ' has extra files: ' . implode(' ', $diff)); - else - $this->assertTrue(true); - } - - /** - * For a given translation locale found, make sure that each translation - * set has the appropriate keys for a complete translation. - * This is relaxed for sublocales (eg fr-CA), which are only - * expected to provide variations for a parent locale. - * - * @dataProvider translations - */ - public function testMissingKeys($locale) - { - $found = array_intersect($this->foundSets($locale),$this->expected); - $diff = []; - foreach ($found as $keyset) - { - $group = substr($keyset, 0, -4); - $expected = $this->loadKeys($keyset); - $actual = $this->loadKeys($keyset, $locale); - $missing = array_diff_key($expected, $actual); - foreach ($missing as $key => $value) - $diff[] = $group . '.' . $key; - } - if (count($diff) > 0) - $this->fail($locale . ' is missing keys: ' . implode(' ', $diff)); - else - $this->assertTrue(true); - } - - /** - * For a given translation locale found, make sure that each translation - * doesn't have extra (un-needed) keys defined.. - * - * @dataProvider translations - */ - public function testExtraKeys($locale) - { - $found = array_intersect($this->foundSets($locale),$this->expected); - $diff = []; - foreach ($found as $keyset) - { - $group = substr($keyset, 0, -4); - $expected = $this->loadKeys($keyset); - $actual = $this->loadKeys($keyset, $locale); - $missing = array_diff_key($actual,$expected); - foreach ($missing as $key => $value) - $diff[] = $group . '.' . $key; - } - if (count($diff) > 0) - $this->fail($locale . ' has extra keys: ' . implode(' ', $diff)); - else - $this->assertTrue(true); - } - - /** - * Identify all the translation sets in system/Language/en - * - * @return [] - */ - public function expectedSets() - { - $dir = getcwd() . '/vendor/codeigniter4/framework/system/Language/en/'; - $dh = opendir($dir); - $sets = []; - while (($file = readdir($dh)) !== false) - { - if (substr($file, 0, 1) != '.') - $sets[] = $file; - } - closedir($dh); - ksort($sets); - return $sets; - } - - /** - * Identify all the translation sets found for a given locale - * - * @return [] - */ - public function foundSets($locale) - { - $dir = getcwd() . '/Language/' . $locale . '/'; - $dh = opendir($dir); - $sets = []; - while (($file = readdir($dh)) !== false) - { - if (substr($file, 0, 1) != '.') - $sets[] = $file; - } - closedir($dh); - ksort($sets); - return $sets; - } - - /** - * Load a set of translations, from the repo or "stock". - * - * @return [] - */ - public function loadKeys($which, $locale = null) - { - $folder = $locale ? getcwd() . '/Language/' . $locale . '/' : - getcwd() . '/vendor/codeigniter4/framework/system/Language/en/'; - $file = $folder . $which; - $keys = require $file; - return $keys; - } - -} From ac36ad1a0d688a53f845dd5006fc4da2dce5e00e Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 26 Nov 2020 17:54:45 +0800 Subject: [PATCH 5/7] Replace travis with github actions --- .github/scripts/continuous-integration | 78 ++++++++++++++++++++++++++ .github/workflows/build.yml | 72 ++++++++++++++++++++++++ .travis.yml | 22 -------- 3 files changed, 150 insertions(+), 22 deletions(-) create mode 100644 .github/scripts/continuous-integration create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/scripts/continuous-integration b/.github/scripts/continuous-integration new file mode 100644 index 00000000..5b6a2229 --- /dev/null +++ b/.github/scripts/continuous-integration @@ -0,0 +1,78 @@ +#!/usr/bin/env php + Date: Thu, 26 Nov 2020 19:53:49 +0800 Subject: [PATCH 6/7] Update documentation --- CONTRIBUTING.md | 84 ++++++++++++++++++++++++++++++++----------------- MISSING.rst | 10 +----- README.rst | 14 ++++----- tests/README.md | 60 +++++++++-------------------------- 4 files changed, 78 insertions(+), 90 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f264854..41f0d1d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,22 +1,20 @@ -# Contributing to the CodeIgniter 4 translations +# Contributing to the CodeIgniter 4 Translations -We welcome contributions, to the *develop* branch, - to add new translations or update existing ones. +We welcome contributions, to the **develop** branch, to add new translations or update existing ones. If you have a translation or correction, please fork the repository, clone it -locally, and then create a new branch (from develop) -for each set of related changes or for -a complete language pack. Once your branch is complete, *then* create a pull +locally, and then create a new branch (from `develop`) for each set of related changes +or for a complete language pack. Once your branch is complete, create a pull request to merge it into the develop branch of this repository. If you are contributing a variant of a main locale (e.g. "en-CA"), you only need to provide those translations that differ from it. Each translation set would go inside a folder named following the two-letter ISO-639-1 language code. -Localization variants would have folders named with the two-letter ISO 639-1 language code in lowercase, -followed by the two-letter ISO 3166 country code capitalized, -and with the two parts separated by a hyphen. -An example would be "en" for English, and "en-US" for the variations appropriate to the United States. +Localization variants would have folders named with the two-letter ISO 639-1 language code in lowercase, +followed by the two-letter ISO 3166 country code capitalized, +and with the two parts separated by a hyphen. An example would be "en" for English, and "en-US" for the +variations appropriate to the United States. Pull requests to the repository will only be considered if they come from the maintainer for any translations in the request, or if the maintainer @@ -31,32 +29,62 @@ PR conversations should be conducted in English, thanks. We would like to see GPG-signed commits for contributions, and we have unit testing to help determine if your translations are complete. -The unit testing looks for translation sets missing language settings that -are in the framework repository's `app/Language/en folder`, and for settings +The unit testing looks for translation sets' missing language settings that +are in the framework repository's `system/Language/en/ folder`, and for settings in a translation set that are not in that folder. -The unit testing is expected to fail, unless all translation sets are totally -in synch with the framework's. Look for your language set in the travis-ci -details for your pull request. +Unit tests for a specific locale should pass. Failures would be thrown to clearly +show which files are missing or extra or which language strings are missing or extra. -For instance, a travis-ci excerpt showing that the `fa` translation is missing -a specific set of messages: +For instance, a test error showing that the `de` translation has extra files not found in the framework: - 12) CodeIgniter\Language\TranslationsTest::testExtraFiles with data set "fa" ('fa') - fa has extra files: Filter.php + 1) CodeIgniter\Language\GermanTranslationTest::testAllTranslatedLanguageFilesAreConfigured with data set "de" ('de') + Failed asserting that translated language file "Seed.php" in "de" locale is configured in the main repository. + Failed asserting that an array is empty. -This was caused by `Filters.php` incorrectly named `Filter,php`. +Another example showing missing files in the `de` translation set: -An example showing missing keys for the `sk` translation set: + 2) CodeIgniter\Language\GermanTranslationTest::testAllConfiguredLanguageFilesAreTranslated with data set "de" ('de') + Failed asserting that language file "CLI.php" in the main repository is translated in "de" locale. + Failed asserting that an array is empty. - 10) CodeIgniter\Language\TranslationsTest::testMissingFiles with data set "sk" ('sk') - sk is missing: RESTful.php Email.php Encryption.php +An example showing missing keys for the `de` translation set: -These would be caused by message sets added to the framework but not here. + 3) CodeIgniter\Language\GermanTranslationTest::testAllConfiguredLanguageKeysAreIncluded with data set "de" ('de') + Failed asserting that the language keys "CLI.altCommandPlural", "CLI.altCommandSingular", "CLI.generateClassName", "CLI.generateFileError", "CLI.generateFileExists", "CLI.generateFileSuccess", "CLI.generateParentClass", "CLI.namespaceNotDefined", "Database.emptyDataset", "Database.emptyPrimaryKey", "Email.sent", "Fabricator.createFailed", "Format.invalidFormatter", "Format.invalidMime", "HTTP.invalidSameSiteSetting", "Migrations.batch", "Migrations.group", "Migrations.missingTable", "Migrations.nameSeeder", "Migrations.namespace", "Session.invalidSameSiteSetting", "Validation.not_in_list" in the main repository are included for translation in "de" locale. + Failed asserting that an array is empty. -And an example showing extra keys for the `it` translation set: +Lastly, an example showing extra keys for the `de` translation set: - 33) CodeIgniter\Language\TranslationsTest::testExtraKeys with data set "it" ('it') - it has extra keys: Files.invalidFilename Files.cannotCopy Images.unsupportedImagecreate + 4) CodeIgniter\Language\GermanTranslationTest::testAllIncludedLanguageKeysAreConfigured with data set "de" ('de') + Failed asserting that the translated language keys "Migrations.badCreateName", "Migrations.writeError" in "de" locale are configured in the main repository. + Failed asserting that an array is empty. -This would be caused by messages removed or renamed in the framework, and not reflected here. +The failure messages are fully descriptive of what went wrong in the translation process. + +## Extending Unit Tests + +Each language locale in this repository has a corresponding test class located in `tests/Language/` folder. +These test classes test individually the language sets for its completeness and precision. However, the test +class `CodeIgniter\Language\AllLocalesTranslationTest` tests **ALL** locales at once. This is used for a +full-blown testing of all language sets. + +When adding a new locale for translation, the following steps should be followed strictly: + +1. Make sure the language files to be translated are found in the framework's main repository. +2. Create a new test class in `tests/Language` folder. For example, the new locale is Canadian French +(fr-CA), then a test class named `CanadianFrenchTranslationTest` will be created. The pattern for naming is +the full name of the new locale followed by `TranslationTest`. +3. This new test class should be extending `CodeIgniter\Language\AbstractTranslationTestCase` and be marked +as a final class. This would not contain any new methods or properties as its sole purpose is to extend +`AbstractTranslationTestCase` for testing the specific locale. +4. In the static `$locales` array of `AbstractTranslationTestCase` this new class should be added. The name +of the new class would be the key and its corresponding locale would be the value. The `$locales` array +should be sorted on the basis of values. +5. Add the details of new locale in [README](README.rst). If the details is originally in +the [MISSING](MISSING.rst), remove the details from there. +6. After that, run the unit tests for your new locale: + + vendor/bin/phpunit --filter CanadianFrenchTranslationTest + +7. When tests all pass, go create a pull request! diff --git a/MISSING.rst b/MISSING.rst index 0d25940b..ed2f33c5 100644 --- a/MISSING.rst +++ b/MISSING.rst @@ -1,5 +1,5 @@ *************************** -Missing/needed translations +Missing/Needed translations *************************** The following languages have translations for CodeIgniter 3, but not yet for CodeIgniter 4: @@ -13,29 +13,21 @@ bn Bengali kabircse Kabir Hossain bg Bulgarian ivantcholakov Ivan Tcholakov ca Catalan Ignasimg Ignasi Molsosa hr Croatian PaleRider981 Mario Ljubicic -cs Czech Ruplahlava Štěpán Postránecký da Danish janhansson* Jan Hansson -nl dutch pkrul Pieter Krul fil filipino dzerium Edzer Josh V. Padilla ... See note below gu Gujarati sajid19991 Sajid Mathupotra hi Hindi shindesushilkumar Sushilkumar Shinde hu Hungarian orionstar László Bóra -ja Japanese ? ? km Khmer Chanthoeun Chanthoeun Kim -fa Persian MSDehghan Mohammad Sadegh ro Romanian CodefishRo Cristian Robert Chiribuc sr Serbian novakurosevic Novak Urosevic ??? sl Slovenian andrejflorjancic Andrej Florjančič sv Swedish peterdenk Peter Denk ta Tamil karthik-code Karthikeyan th Thai ? ? -uk Ukranian flybot Sergiy Kosiy ur Urdu codeonion Muhammad Ali -vi Vietnamese tinhphaistc Trần Xuân Sâm ??? ======== ==================== ================= ========================= Notes: - Filipino has a 639-2 code, while tl (Tagalog) is the 639-1 code; which to use? - - diff --git a/README.rst b/README.rst index fc626087..8f5ab7f5 100644 --- a/README.rst +++ b/README.rst @@ -3,11 +3,11 @@ Translations for CodeIgniter 4 System Messages ############################################## This project contains translations for CodeIgniter 4 -localization, eg. **system/Language/en**. +localization, e.g. **system/Language/en/**. Copy the folder(s) for the locales you are interested in, from inside the **Language** folder of this project to your -**application/Language** folder. +**app/Language/** folder. You may then use the CodeIgniter Language class to reference the translations directly ... see the `User Guide `_. @@ -15,9 +15,9 @@ directly ... see the `User Guide `_. Each translation set would go inside a folder named following the two-letter language code from here. -Localization variants are provided for, as folders named with the two-letter ISO 639-1 language code in lowercase, -followed by the two-letter `ISO 3166 country code `_ capitalized, -and with the two parts separated by a hyphen. +Localization variants are provided for, as folders named with the two-letter ISO 639-1 language code in lowercase, +followed by the two-letter `ISO 3166 country code `_ capitalized, +and with the two parts separated by a hyphen. An example would be "en" for English, and "en-US" for the variations appropriate to the United States. ********************** @@ -47,7 +47,7 @@ ko Korean 4.0.0* Timothy-Y-H-Lee Timothy-Y-H-Lee lt Lithuanian 4.0.0* dgvirtual Donatas Glodenis lv Latvian 4.0.0* davislasis Dāvis Lasis ml Malayalam 4.0.0 rakheshthayyur Rakhesh Thayyur -nl Dutch 4.0.0 JohanSmolders JohanSmolders +nl Dutch 4.0.0 JohanSmolders JohanSmolders no Norwegian 4.0.0 LA3QMA Kai Günter Brandt pl Polish 4.0.0 DEVELPL Maciej Jasiewicz pt Portugese 4.0.0 rbm0407 Rodrigo Borges @@ -72,5 +72,3 @@ License ******* These translations are licensed under the `MIT license `_. - -`Jim Parry `_ diff --git a/tests/README.md b/tests/README.md index 9ece18fc..93107af0 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,15 +1,15 @@ # Running System Tests -This is the quick-start to CodeIgniter testing. Its intent is to describe what -it takes to get your system setup and ready to run the system tests. -It is not intended to be a full description of the test features that you can -use to test your application, since that can be found in the documentation. +This is the quick-start to CodeIgniter testing. Its intent is to describe what +it takes to get your system setup and ready to run the system tests. +It is not intended to be a full description of the test features that you can +use to test your application, since that can be found in the documentation. ## Requirements -It is recommended to use the latest version of PHPUnit. At the time of this -writing we are running version 7.5.1. Support for this has been built into the -**composer.json** file that ships with CodeIgniter, and can easily be installed +It is recommended to use the latest version of PHPUnit. At the time of this +writing we are running version 8.5.9. Support for this has been built into the +**composer.json** file that ships with CodeIgniter, and can easily be installed via [Composer](https://getcomposer.org/) if you don't already have it installed globally. > composer install @@ -18,54 +18,25 @@ If running under OS X or Linux, you can create a symbolic link to make running t > ln -s ./vendor/bin/phpunit ./phpunit -You also need to install [XDebug](https://xdebug.org/index.php) in order -for the unit tests to successfully complete. - -## Setup - -A number of the tests that are ran during the test suite are ran against a running database. -In order to setup the database used here, edit the details for the `tests` database -group in **app/Config/Database.php**. Make sure that you provide a database engine -that is currently running, and have already created a table that you can use only -for these tests, as it will be wiped and refreshed often while running the test suite. - -If you want to run the tests without running the live database tests, -you can exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml**, -call it **phpunit.xml**, and un-comment the line within the testsuite that excludes -the **tests/system/Database/Live** directory. This will make the tests run quite a bit faster. - -## Running the tests +## Running the Tests The entire test suite can be ran by simply typing one command from the command line within the main directory. > ./phpunit -You can limit tests to those within a single test directory by specifying the -directory name after phpunit. All core tests are stored under **tests/system**. - - > ./phpunit tests/system/HTTP/ - -Individual tests can be ran by including the relative path to the test file. - - > ./phpunit tests/system/HTTP/RequestTest - -You can run the tests without running the live database tests. - - > ./phpunit --exclude-group DatabaseLive - ## Generating Code Coverage -To generate coverage information, including HTML reports you can view in your browser, -you can use the following command: +To generate coverage information, including HTML reports you can view in your browser, +you can use the following command: > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m -This runs all of the tests again, collecting information about how many lines, -functions, and files are tested, and the percent of the code that is covered by the tests. -It is collected in two formats: a simple text file that provides an overview, -as well as comprehensive collection of HTML files that show the status of every line of code in the project. +This runs all of the tests again, collecting information about how many lines, +functions, and files are tested, and the percent of the code that is covered by the tests. +It is collected in two formats: a simple text file that provides an overview, +as well as comprehensive collection of HTML files that show the status of every line of code in the project. -The text file can be found at **tests/coverage.txt**. +The text file can be found at **tests/coverage.txt**. The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser. ## PHPUnit XML Configuration @@ -78,4 +49,3 @@ The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml`` (which is git ignored), and to tailor yours as you see fit. For instance, you might wish to exclude database tests or automatically generate HTML code coverage reports. - From 50c3bc077d324d4f812aced01cb308c7c2797f44 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sat, 28 Nov 2020 20:27:15 +0800 Subject: [PATCH 7/7] Bump CI/CD requirements --- .github/workflows/build.yml | 4 ++-- .gitignore | 5 ++--- composer.json | 6 +++--- phpunit.xml.dist | 11 ++++++----- tests/README.md | 33 +++++++++++---------------------- 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b4b9a4e8..c3255c06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,14 +26,14 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.3', '7.4'] steps: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} tools: composer diff --git a/.gitignore b/.gitignore index 3762813f..a222299f 100644 --- a/.gitignore +++ b/.gitignore @@ -86,6 +86,5 @@ nb-configuration.xml # Visual Studio Code .vscode/ -/results/ -/phpunit*.xml -/.phpunit.*.cache +phpunit.xml +.phpunit.cache/ diff --git a/composer.json b/composer.json index 2567eea0..3ff80961 100644 --- a/composer.json +++ b/composer.json @@ -5,12 +5,12 @@ "homepage": "https://codeigniter.com", "license": "MIT", "require": { - "php": ">=7.2", + "php": "^7.2", "ext-intl": "*" }, "require-dev": { "codeigniter4/codeigniter4": "dev-develop", - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.4" }, "config": { "optimize-autoloader": true, @@ -30,7 +30,7 @@ "repositories": [ { "type": "vcs", - "url": "https://github.com/codeigniter4/codeigniter4", + "url": "https://github.com/codeigniter4/CodeIgniter4", "canonical": true } ], diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4dd38cd9..a0f07364 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,8 @@ - - + + Language - - + + diff --git a/tests/README.md b/tests/README.md index 93107af0..28df75e9 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,4 +1,4 @@ -# Running System Tests +# Running Translations Tests This is the quick-start to CodeIgniter testing. Its intent is to describe what it takes to get your system setup and ready to run the system tests. @@ -8,36 +8,27 @@ use to test your application, since that can be found in the documentation. ## Requirements It is recommended to use the latest version of PHPUnit. At the time of this -writing we are running version 8.5.9. Support for this has been built into the +writing we are running version `9.x`. Support for this has been built into the **composer.json** file that ships with CodeIgniter, and can easily be installed via [Composer](https://getcomposer.org/) if you don't already have it installed globally. - > composer install + composer update If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer. - > ln -s ./vendor/bin/phpunit ./phpunit + ln -s ./vendor/bin/phpunit ./phpunit ## Running the Tests -The entire test suite can be ran by simply typing one command from the command line within the main directory. +The entire test suite can be ran by simply running the command below: - > ./phpunit + ./phpunit --filter AllLocalesTranslationTest -## Generating Code Coverage +To run the specific test suite for a locale, simply provide the class name of the locale-specific test: -To generate coverage information, including HTML reports you can view in your browser, -you can use the following command: + ./phpunit --filter FrenchTranslationTest - > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m - -This runs all of the tests again, collecting information about how many lines, -functions, and files are tested, and the percent of the code that is covered by the tests. -It is collected in two formats: a simple text file that provides an overview, -as well as comprehensive collection of HTML files that show the status of every line of code in the project. - -The text file can be found at **tests/coverage.txt**. -The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser. +Locale-specific test class names follow the named regex pattern `/^(?P[A-Za-z]+)TranslationTest$/`. ## PHPUnit XML Configuration @@ -45,7 +36,5 @@ The repository has a ``phpunit.xml.dist`` file in the project root, used for PHPUnit configuration. This is used as a default configuration if you do not have your own ``phpunit.xml`` in the project root. -The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml`` -(which is git ignored), and to tailor yours as you see fit. -For instance, you might wish to exclude database tests -or automatically generate HTML code coverage reports. +The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml`` (which is git ignored), +and to tailor yours as you see fit.