Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
Release 4.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Jun 24, 2020
2 parents 3cc5509 + 5e34686 commit 6c32988
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.4.2]
- Fixed issue where locale files from higher priority locations would not overwrite files from lower priority locations. (N.B.: This fix means the files withing the same locations will be loaded in BACKWARD order. Having the location order is more important in this case.)

## [4.4.1]
- Throws an exception if `translate` placeholder are not numeric or array.
- Fix issue with numeric placeholder with non plural keys. See [userfrosting#1090](https://github.com/userfrosting/UserFrosting/issues/1090#issuecomment-620832985).
Expand Down Expand Up @@ -61,6 +64,7 @@ See updated [documentation](README.md) for more details on how to use the new Tr
## 4.0.0
- Initial release

[4.4.2]: https://github.com/userfrosting/i18n/compare/4.4.1...4.4.2
[4.4.1]: https://github.com/userfrosting/i18n/compare/4.4.0...4.4.1
[4.4.0]: https://github.com/userfrosting/i18n/compare/4.3.0...4.4.0
[4.3.0]: https://github.com/userfrosting/i18n/compare/4.2.1...4.3.0
Expand Down
5 changes: 4 additions & 1 deletion src/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ protected function filterDictionaryFiles(array $files): array
*/
protected function getFiles(): array
{
return $this->locator->listResources($this->uri.$this->locale->getIdentifier(), true);
$ressources = $this->locator->listResources($this->uri.$this->locale->getIdentifier(), true);
$ressources = array_reverse($ressources);

return $ressources;
}
}
25 changes: 12 additions & 13 deletions tests/DictionaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,33 +180,32 @@ public function testGetDictionary_withNoDependentLocaleWithManyFiles(): void

// Prepare mocked locale - aa_bb
$locale = Mockery::mock(Locale::class);
$locale->shouldReceive('getDependentLocales')->andReturn([]);
$locale->shouldReceive('getDependentLocalesIdentifier')->andReturn([]);
$locale->shouldReceive('getIdentifier')->andReturn('aa_bb');
$locale->shouldReceive('getDependentLocales')->once()->andReturn([]);
$locale->shouldReceive('getIdentifier')->twice()->andReturn('aa_bb');

// Prepare first mock Resource - File `Foo/Bar/File1.php`
$file1 = Mockery::mock(Resource::class);
$file1->shouldReceive('getExtension')->andReturn('php');
$file1->shouldReceive('__toString')->andReturn('Foo/Bar/File1.php');
$file1->shouldReceive('getExtension')->once()->andReturn('php');
$file1->shouldReceive('__toString')->once()->andReturn('Foo/Bar/File1.php');

// Prepare second mock Resource - File `Bar/Foo/File2.php`
$file2 = Mockery::mock(Resource::class);
$file2->shouldReceive('getExtension')->andReturn('php');
$file2->shouldReceive('__toString')->andReturn('Bar/Foo/File2.php');
$file2->shouldReceive('getExtension')->once()->andReturn('php');
$file2->shouldReceive('__toString')->once()->andReturn('Bar/Foo/File2.php');

// Prepare Third mock Resource - non `.php` file
$file3 = Mockery::mock(Resource::class);
$file3->shouldReceive('getExtension')->andReturn('txt');
$file3->shouldReceive('getExtension')->once()->andReturn('txt');
$file3->shouldNotReceive('__toString');

// Prepare mock Locator - Return the file
$locator = Mockery::mock(ResourceLocator::class);
$locator->shouldReceive('listResources')->with('locale://aa_bb', true)->andReturn([$file1, $file2, $file3]);
$locator->shouldReceive('listResources')->with('locale://aa_bb', true)->once()->andReturn([$file1, $file2, $file3]);

// Prepare mock FileLoader - Will return the mock file, with a mock data
$fileLoader = Mockery::mock(ArrayFileLoader::class);
$fileLoader->shouldReceive('setPaths')->with(['Foo/Bar/File1.php', 'Bar/Foo/File2.php']);
$fileLoader->shouldReceive('load')->andReturn($expectedResult);
$fileLoader->shouldReceive('setPaths')->once();
$fileLoader->shouldReceive('load')->once()->andReturn($expectedResult);

// Get dictionary
$dictionary = new Dictionary($locale, $locator, $fileLoader);
Expand Down Expand Up @@ -539,9 +538,9 @@ public function testGetDictionary_withRealLocale(): void
$dictionary = new Dictionary($locale, $this->locator);

$expectedResult = [
'FOO' => 'Foo', // bar/bar.php file will be loaded first
'FOO' => 'BAR', // bar/bar.php file will be loaded first
'CAR' => 'Coche',
'BAR' => 'FooFoo', // ...but zzz/bar.php will be loaded LAST because of alphabetical order !
'BAR' => 'Bar', // ...but zzz/bar.php will be loaded LAST because of alphabetical order !
];

$data = $dictionary->getDictionary();
Expand Down

0 comments on commit 6c32988

Please sign in to comment.