Skip to content

Commit

Permalink
Merge pull request #172 from paulbalandan/bug/namespace-fix
Browse files Browse the repository at this point in the history
Fix namespace ignored by CI4 autoloader
  • Loading branch information
paulbalandan authored Dec 4, 2020
2 parents 7917299 + b404d43 commit c967e65
Show file tree
Hide file tree
Showing 30 changed files with 47 additions and 47 deletions.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ show which files are missing or extra or which language strings are missing or e

For instance, a test error showing that the `de` translation has extra files not found in the framework:

1) CodeIgniter\Language\GermanTranslationTest::testAllTranslatedLanguageFilesAreConfigured with data set "de" ('de')
1) Translations\Tests\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.

Another example showing missing files in the `de` translation set:

2) CodeIgniter\Language\GermanTranslationTest::testAllConfiguredLanguageFilesAreTranslated with data set "de" ('de')
2) Translations\Tests\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.

An example showing missing keys for the `de` translation set:

3) CodeIgniter\Language\GermanTranslationTest::testAllConfiguredLanguageKeysAreIncluded with data set "de" ('de')
3) Translations\Tests\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.

Lastly, an example showing extra keys for the `de` translation set:

4) CodeIgniter\Language\GermanTranslationTest::testAllIncludedLanguageKeysAreConfigured with data set "de" ('de')
4) Translations\Tests\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.

Expand All @@ -66,7 +66,7 @@ The failure messages are fully descriptive of what went wrong in the translation

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
class `Translations\Tests\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:
Expand All @@ -75,7 +75,7 @@ When adding a new locale for translation, the following steps should be followed
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
3. This new test class should be extending `Translations\Tests\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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
},
"autoload": {
"psr-4": {
"CodeIgniter\\Language\\": "Language/"
"Translations\\": ""
}
},
"autoload-dev": {
"psr-4": {
"CodeIgniter\\Language\\": "tests/Language/"
"Translations\\Tests\\": "tests/Language/"
}
},
"repositories": [
Expand Down
24 changes: 12 additions & 12 deletions tests/Language/AbstractTranslationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -107,7 +107,7 @@ final public function testAllConfiguredLanguageFilesAreTranslated(string $locale
sort($filesNotTranslated);
$count = count($filesNotTranslated);

$this->assertEmpty($filesNotTranslated, sprintf(
self::assertEmpty($filesNotTranslated, sprintf(
'Failed asserting that language %s "%s" in the main repository %s translated in "%s" locale.',
$count > 1 ? 'files' : 'file',
implode('", "', $filesNotTranslated),
Expand Down Expand Up @@ -136,7 +136,7 @@ final public function testAllTranslatedLanguageFilesAreConfigured(string $locale
sort($filesNotConfigured);
$count = count($filesNotConfigured);

$this->assertEmpty($filesNotConfigured, sprintf(
self::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),
Expand All @@ -157,7 +157,7 @@ final public function testAllTranslatedLanguageFilesAreConfigured(string $locale
*/
final public function testAllConfiguredLanguageKeysAreIncluded(string $locale): void
{
$availableSets = array_intersect($this->expectedSets(), $this->foundSets($locale));
$availableSets = array_intersect($this->expectedSets(), $this->foundSets($locale));
$keysNotIncluded = [];

foreach ($availableSets as $file)
Expand All @@ -176,7 +176,7 @@ final public function testAllConfiguredLanguageKeysAreIncluded(string $locale):
sort($keysNotIncluded);
$count = count($keysNotIncluded);

$this->assertEmpty($keysNotIncluded, sprintf(
self::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),
Expand All @@ -197,7 +197,7 @@ final public function testAllConfiguredLanguageKeysAreIncluded(string $locale):
*/
final public function testAllIncludedLanguageKeysAreConfigured(string $locale): void
{
$availableSets = array_intersect($this->expectedSets(), $this->foundSets($locale));
$availableSets = array_intersect($this->expectedSets(), $this->foundSets($locale));
$keysNotConfigured = [];

foreach ($availableSets as $file)
Expand All @@ -216,7 +216,7 @@ final public function testAllIncludedLanguageKeysAreConfigured(string $locale):
sort($keysNotConfigured);
$count = count($keysNotConfigured);

$this->assertEmpty($keysNotConfigured, sprintf(
self::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),
Expand Down Expand Up @@ -248,7 +248,7 @@ final public function testAllLocalesHaveCorrespondingTestCaseInArray(): void
sort($untestedLocales);
$count = count($untestedLocales);

$this->assertEmpty($untestedLocales, sprintf(
self::assertEmpty($untestedLocales, sprintf(
'Failed asserting that %s "%s" %s corresponding test %s in %s::$locales array.',
$count > 1 ? 'locales' : 'locale',
implode('", "', $untestedLocales),
Expand All @@ -267,7 +267,7 @@ final public function testAllLocalesHaveCorrespondingTestCaseInArray(): void
*/
final public function testAllLocalesHaveCorrespondingTestCaseFiles(string $class): void
{
$this->assertTrue(class_exists($class, false), sprintf(
self::assertTrue(class_exists($class, false), sprintf(
'Failed asserting that test class "%s" is existing.',
$class
));
Expand Down Expand Up @@ -301,7 +301,7 @@ final public function translationKeys(): array

foreach ($dirs as $dir)
{
$dir = trim($dir, '\\/');
$dir = trim($dir, '\\/');
$sets[$dir] = [$dir];
}

Expand Down Expand Up @@ -339,7 +339,7 @@ final public function loadFile(string $file, ?string $locale = null): array
/**
* Gets the set of language files for each location.
*
* @param string|null $locale
* @param null|string $locale
*
* @return array
*/
Expand All @@ -349,7 +349,7 @@ private function translationSets(?string $locale = null): array
? getcwd() . "/Language/{$locale}/"
: getcwd() . self::MAIN_LANGUAGE_REPO;

$sets = [];
$sets = [];
$files = directory_map($location, 1);

foreach ($files as $file)
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/AllLocalesTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/ArabicTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/BrazilianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/CzechTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/DutchTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/FarsiTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/FrenchTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/GermanTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/IndonesianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/ItalianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/JapaneseTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/KoreanTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/LatvianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/LithuanianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/MalayalamTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/NorwegianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/PolishTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/PortugueseTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/RussianTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/SimpleChineseTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/SlovakTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/SpanishTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/SwedishTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/TraditionalChineseTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Language/TurkishTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace CodeIgniter\Language;
namespace Translations\Tests;

/**
* @internal
Expand Down
Loading

0 comments on commit c967e65

Please sign in to comment.