Skip to content

Commit

Permalink
Merge pull request #22 from Laravel-Lang/2.x
Browse files Browse the repository at this point in the history
Namespace was `LaravelLang\NativeLocaleNames\Native` renamed to `LaravelLang\NativeLocaleNames\LocaleNames`
  • Loading branch information
andrey-helldar authored Nov 20, 2023
2 parents 6be8270 + e578436 commit e5f5bf4
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
7 changes: 4 additions & 3 deletions src/Native.php → src/LocaleNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
use LaravelLang\NativeLocaleNames\Enums\SortBy;
use LaravelLang\NativeLocaleNames\Helpers\Arr;
use LaravelLang\NativeLocaleNames\Helpers\Path;
use LaravelLang\NativeLocaleNames\Services\Filesystem;

class Native
class LocaleNames
{
protected static string $default = '_native';
public static string $default = '_native';

public static function get(BackedEnum|string|null $locale = null, SortBy $sortBy = SortBy::Value): array
{
Expand All @@ -42,7 +43,7 @@ protected static function forLocale(string $locale, SortBy $sortBy): array

protected static function load(string $path): array
{
return Arr::file($path);
return Filesystem::load($path);
}

protected static function path(string $locale): bool|string
Expand Down
2 changes: 1 addition & 1 deletion tests/Datasets/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

declare(strict_types=1);

use LaravelLang\Locales\Enums\Locale;
use LaravelLang\LocaleList\Locale;

dataset('locales-string', fn () => Locale::values());
dataset('locales-enum', fn () => Locale::cases());
Expand Down
2 changes: 1 addition & 1 deletion tests/Helpers/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

declare(strict_types=1);

use LaravelLang\Locales\Enums\Locale;
use LaravelLang\LocaleList\Locale;
use LaravelLang\NativeLocaleNames\Enums\SortBy;
use LaravelLang\NativeLocaleNames\Helpers\Arr;
use PHPUnit\Framework\Assert;
Expand Down
5 changes: 3 additions & 2 deletions tests/Helpers/native.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

declare(strict_types=1);

use LaravelLang\NativeLocaleNames\Helpers\Arr;
use LaravelLang\NativeLocaleNames\Helpers\Path;
use LaravelLang\NativeLocaleNames\Services\Filesystem;

function sourceLocale(string $locale): array
{
return Arr::file(__DIR__ . '/../../locales/' . $locale . '/json.json');
return Filesystem::load(Path::resolve($locale));
}
4 changes: 2 additions & 2 deletions tests/Unit/EmptyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

declare(strict_types=1);

use LaravelLang\NativeLocaleNames\Native;
use LaravelLang\NativeLocaleNames\LocaleNames;

it('checks for empty values being passed')
->with('locales-empty')
->expect(fn (?string $locale) => Native::get($locale))
->expect(fn (?string $locale) => LocaleNames::get($locale))
->toBeSameCount()
->toBeCompileLocales()
->not->toBeEmpty();
6 changes: 3 additions & 3 deletions tests/Unit/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

declare(strict_types=1);

use LaravelLang\Locales\Enums\Locale;
use LaravelLang\NativeLocaleNames\Native;
use LaravelLang\LocaleList\Locale;
use LaravelLang\NativeLocaleNames\LocaleNames;

it('checks if the enum matches the locale value', function (Locale $locale) {
expect(Native::get($locale))
expect(LocaleNames::get($locale))
->toBeSameCount()
->toBeLocale($locale)
->not->toBeEmpty();
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/IncorrectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

declare(strict_types=1);

use LaravelLang\NativeLocaleNames\Native;
use LaravelLang\NativeLocaleNames\LocaleNames;

it('checks for a match using the locale string value')
->with('locales-incorrect')
->expect(fn (string $locale) => Native::get($locale))
->expect(fn (string $locale) => LocaleNames::get($locale))
->toBeSameCount()
->toBeCompileLocales()
->not->toBeEmpty();
4 changes: 2 additions & 2 deletions tests/Unit/NativeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
declare(strict_types=1);

use LaravelLang\NativeLocaleNames\Helpers\Arr;
use LaravelLang\NativeLocaleNames\Native;
use LaravelLang\NativeLocaleNames\LocaleNames;

it('should not be a clone of the English version')
->expect(fn () => Native::get())
->expect(fn () => LocaleNames::get())
->toBeSameCount()
->toBe(Arr::sort(sourceLocale('_native')))
->not->toBe(Arr::sort(sourceLocale('en')))
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/SortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
declare(strict_types=1);

use LaravelLang\NativeLocaleNames\Enums\SortBy;
use LaravelLang\NativeLocaleNames\Native;
use LaravelLang\NativeLocaleNames\LocaleNames;

it('checks default sorting', function (string $locale) {
expect(Native::get($locale))
expect(LocaleNames::get($locale))
->toBeSameCount()
->toBeLocale($locale)
->not->toBeEmpty();
})->with('locales-string');

it('checks sorting by key', function (string $locale) {
expect(Native::get($locale, SortBy::Key))
expect(LocaleNames::get($locale, SortBy::Key))
->toBeSameCount()
->toBeLocale($locale, SortBy::Key)
->not->toBeEmpty();
})->with('locales-string');

it('checks sorting by value', function (string $locale) {
expect(Native::get($locale, SortBy::Value))
expect(LocaleNames::get($locale, SortBy::Value))
->toBeSameCount()
->toBeLocale($locale, SortBy::Value)
->not->toBeEmpty();
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/StringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

declare(strict_types=1);

use LaravelLang\NativeLocaleNames\Native;
use LaravelLang\NativeLocaleNames\LocaleNames;

it('checks for a match using the locale string value', function (string $locale) {
expect(Native::get($locale))
expect(LocaleNames::get($locale))
->toBeSameCount()
->toBeLocale($locale)
->not->toBeEmpty();
Expand Down

0 comments on commit e5f5bf4

Please sign in to comment.