diff --git a/lang/lang-country-overrides/lv-LV.json b/lang/lang-country-overrides/lv-LV.json new file mode 100644 index 0000000..2552de0 --- /dev/null +++ b/lang/lang-country-overrides/lv-LV.json @@ -0,0 +1,19 @@ +{ + "country": "LV", + "country_name": "Latvia", + "country_name_local": "Latvija", + "lang": "lv", + "name": "Latviešu", + "date_numbers": "d.m.Y", + "date_numbers_full_capitals": "DD.MM.YYYY", + "date_words_without_day": "Y. \\g\\a\\d\\a j. F", + "date_words_with_day": "l, Y. \\g\\a\\d\\a j. F", + "date_birthday": "j. F", + "time_format": "H:i", + "emoji_flag": "🇱🇻", + "currency_code": "EUR", + "currency_symbol": "€", + "currency_symbol_local": "€", + "currency_name": "Euro", + "currency_name_local": "eiro" +} diff --git a/tests/Feature/LangCountryDataAvailabilityTest.php b/tests/Feature/LangCountryDataAvailabilityTest.php new file mode 100644 index 0000000..fa0a107 --- /dev/null +++ b/tests/Feature/LangCountryDataAvailabilityTest.php @@ -0,0 +1,76 @@ +mapWithKeys(fn (string $langCountry) => [$langCountry => [$langCountry]]) + ->all(); +}); + +it('has a resolvable data file for every allowed lang-country', function (string $langCountry) { + $file = resolveLangCountryFile($langCountry); + + expect($file)->not->toBeNull( + "No data file found for allowed lang-country [{$langCountry}]. " + ."Add lang/lang-country-overrides/{$langCountry}.json." + ); + + $data = json_decode(file_get_contents($file), true); + + expect($data)->toBeArray()->toHaveKeys([ + 'country', + 'country_name', + 'country_name_local', + 'lang', + 'name', + 'date_numbers', + 'date_numbers_full_capitals', + 'date_words_without_day', + 'date_words_with_day', + 'date_birthday', + 'time_format', + 'emoji_flag', + 'currency_code', + 'currency_symbol', + 'currency_symbol_local', + 'currency_name', + 'currency_name_local', + ]); +})->with('allowed_lang_countries'); + +it('can construct LangCountry for every allowed lang-country without error', function (string $langCountry) { + session(['lang_country' => $langCountry]); + + $langCountryInstance = new LangCountry; + + expect($langCountryInstance->currentLangCountry())->toBe($langCountry); +})->with('allowed_lang_countries'); + +it('switches away from a freshly added lang-country without throwing', function () { + session(['lang_country' => 'lv-LV']); + + $response = $this->get(config('lang-country.lang_switcher_uri').'/de-DE'); + + $response->assertRedirect(); + expect(session('lang_country'))->toBe('de-DE'); +});