From 35d47065682d7de0b64098cc7b2f66d1412ebe10 Mon Sep 17 00:00:00 2001 From: bernhard Date: Sat, 11 Nov 2023 15:55:41 +0100 Subject: [PATCH 1/2] Issue #205: no need to use Lingua::Traslit with indirect object syntax Indirect object syntax is just mentioned in the documentation. But the regular constructor syntax works just as well. --- Kernel/System/Console/Command/Dev/Tools/TranslationsUpdate.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/System/Console/Command/Dev/Tools/TranslationsUpdate.pm b/Kernel/System/Console/Command/Dev/Tools/TranslationsUpdate.pm index 5cd1245f54..e454be5af1 100644 --- a/Kernel/System/Console/Command/Dev/Tools/TranslationsUpdate.pm +++ b/Kernel/System/Console/Command/Dev/Tools/TranslationsUpdate.pm @@ -628,7 +628,7 @@ sub HandleLanguage { }, ); if ( $TranslitLanguagesMap{$Language} ) { - $TranslitObject = new Lingua::Translit( $TranslitLanguagesMap{$Language}->{TranslitTable} ); ## no critic qw(Objects::ProhibitIndirectSyntax) + $TranslitObject = Lingua::Translit->new( $TranslitLanguagesMap{$Language}->{TranslitTable} ); $TranslitLanguageCoreObject = Kernel::Language->new( UserLanguage => $TranslitLanguagesMap{$Language}->{SourceLanguage}, TranslationFile => 1, From 96023fb3ff536809d27a778fb25eedd9b5576808 Mon Sep 17 00:00:00 2001 From: bernhard Date: Sat, 11 Nov 2023 15:57:53 +0100 Subject: [PATCH 2/2] Issue #205: test for complete list of countries the list should be stable because Locale::Codes is Kernel/cpan-lib Testing for the exact result also reduces the number of test cases. It will also be easier to detect future changes. --- scripts/test/ReferenceData.t | 313 ++++++++++++++++++++++++++++++----- 1 file changed, 272 insertions(+), 41 deletions(-) diff --git a/scripts/test/ReferenceData.t b/scripts/test/ReferenceData.t index d2a8e6ec29..71280e94ee 100644 --- a/scripts/test/ReferenceData.t +++ b/scripts/test/ReferenceData.t @@ -39,53 +39,284 @@ $ConfigObject->Set( my $ReferenceDataObject = $Kernel::OM->Get('Kernel::System::ReferenceData'); # tests the method to make sure there are at least 100 countries -my $CountryExists = $ReferenceDataObject->CountryList; +my $CountryList1 = $ReferenceDataObject->CountryList; -my $CountryListLength = scalar keys $CountryExists->%*; -ok( $CountryListLength > 100, "There are $CountryListLength countries registered" ); - -my @CountryList = ( - 'Netherlands', - 'Germany', - 'Switzerland', - 'United States of America', - 'Japan', - 'South Sudan', - - # 'Kosovo', not yet in the list - 'North Macedonia', - 'Eswatini', - 'Tonga' +my %LocaleCodesCountryList = ( + "Afghanistan" => "Afghanistan", + "Aland Islands" => "Aland Islands", + "Albania" => "Albania", + "Algeria" => "Algeria", + "American Samoa" => "American Samoa", + "Andorra" => "Andorra", + "Angola" => "Angola", + "Anguilla" => "Anguilla", + "Antarctica" => "Antarctica", + "Antigua and Barbuda" => "Antigua and Barbuda", + "Argentina" => "Argentina", + "Armenia" => "Armenia", + "Aruba" => "Aruba", + "Australia" => "Australia", + "Austria" => "Austria", + "Azerbaijan" => "Azerbaijan", + "Bahamas" => "Bahamas", + "Bahrain" => "Bahrain", + "Bangladesh" => "Bangladesh", + "Barbados" => "Barbados", + "Belarus" => "Belarus", + "Belgium" => "Belgium", + "Belize" => "Belize", + "Benin" => "Benin", + "Bermuda" => "Bermuda", + "Bhutan" => "Bhutan", + "Bolivia (Plurinational State of)" => "Bolivia (Plurinational State of)", + "Bonaire, Sint Eustatius and Saba" => "Bonaire, Sint Eustatius and Saba", + "Bosnia and Herzegovina" => "Bosnia and Herzegovina", + "Botswana" => "Botswana", + "Bouvet Island" => "Bouvet Island", + "Brazil" => "Brazil", + "British Indian Ocean Territory" => "British Indian Ocean Territory", + "Brunei Darussalam" => "Brunei Darussalam", + "Bulgaria" => "Bulgaria", + "Burkina Faso" => "Burkina Faso", + "Burundi" => "Burundi", + "Cabo Verde" => "Cabo Verde", + "Cambodia" => "Cambodia", + "Cameroon" => "Cameroon", + "Canada" => "Canada", + "Cayman Islands" => "Cayman Islands", + "Central African Republic" => "Central African Republic", + "Chad" => "Chad", + "Chile" => "Chile", + "China" => "China", + "Christmas Island" => "Christmas Island", + "Cocos (Keeling) Islands" => "Cocos (Keeling) Islands", + "Colombia" => "Colombia", + "Comoros" => "Comoros", + "Congo" => "Congo", + "Congo (The Democratic Republic of the)" => "Congo (The Democratic Republic of the)", + "Cook Islands" => "Cook Islands", + "Costa Rica" => "Costa Rica", + "Cote d'Ivoire" => "Cote d'Ivoire", + "Croatia" => "Croatia", + "Cuba" => "Cuba", + "Curacao" => "Curacao", + "Cyprus" => "Cyprus", + "Czechia" => "Czechia", + "Denmark" => "Denmark", + "Djibouti" => "Djibouti", + "Dominica" => "Dominica", + "Dominican Republic" => "Dominican Republic", + "Ecuador" => "Ecuador", + "Egypt" => "Egypt", + "El Salvador" => "El Salvador", + "Equatorial Guinea" => "Equatorial Guinea", + "Eritrea" => "Eritrea", + "Estonia" => "Estonia", + "Eswatini" => "Eswatini", + "Ethiopia" => "Ethiopia", + "Falkland Islands (The) [Malvinas]" => "Falkland Islands (The) [Malvinas]", + "Faroe Islands" => "Faroe Islands", + "Fiji" => "Fiji", + "Finland" => "Finland", + "France" => "France", + "French Guiana" => "French Guiana", + "French Polynesia" => "French Polynesia", + "French Southern Territories" => "French Southern Territories", + "Gabon" => "Gabon", + "Gambia" => "Gambia", + "Georgia" => "Georgia", + "Germany" => "Germany", + "Ghana" => "Ghana", + "Gibraltar" => "Gibraltar", + "Greece" => "Greece", + "Greenland" => "Greenland", + "Grenada" => "Grenada", + "Guadeloupe" => "Guadeloupe", + "Guam" => "Guam", + "Guatemala" => "Guatemala", + "Guernsey" => "Guernsey", + "Guinea" => "Guinea", + "Guinea-Bissau" => "Guinea-Bissau", + "Guyana" => "Guyana", + "Haiti" => "Haiti", + "Heard Island and McDonald Islands" => "Heard Island and McDonald Islands", + "Holy See" => "Holy See", + "Honduras" => "Honduras", + "Hong Kong" => "Hong Kong", + "Hungary" => "Hungary", + "Iceland" => "Iceland", + "India" => "India", + "Indonesia" => "Indonesia", + "Iran (Islamic Republic of)" => "Iran (Islamic Republic of)", + "Iraq" => "Iraq", + "Ireland" => "Ireland", + "Isle of Man" => "Isle of Man", + "Israel" => "Israel", + "Italy" => "Italy", + "Jamaica" => "Jamaica", + "Japan" => "Japan", + "Jersey" => "Jersey", + "Jordan" => "Jordan", + "Kazakhstan" => "Kazakhstan", + "Kenya" => "Kenya", + "Kiribati" => "Kiribati", + "Korea, The Democratic People's Republic of" => "Korea, The Democratic People's Republic of", + "Korea, The Republic of" => "Korea, The Republic of", + "Kuwait" => "Kuwait", + "Kyrgyzstan" => "Kyrgyzstan", + "Lao People's Democratic Republic" => "Lao People's Democratic Republic", + "Latvia" => "Latvia", + "Lebanon" => "Lebanon", + "Lesotho" => "Lesotho", + "Liberia" => "Liberia", + "Libya" => "Libya", + "Liechtenstein" => "Liechtenstein", + "Lithuania" => "Lithuania", + "Luxembourg" => "Luxembourg", + "Macao" => "Macao", + "Madagascar" => "Madagascar", + "Malawi" => "Malawi", + "Malaysia" => "Malaysia", + "Maldives" => "Maldives", + "Mali" => "Mali", + "Malta" => "Malta", + "Marshall Islands" => "Marshall Islands", + "Martinique" => "Martinique", + "Mauritania" => "Mauritania", + "Mauritius" => "Mauritius", + "Mayotte" => "Mayotte", + "Mexico" => "Mexico", + "Micronesia (Federated States of)" => "Micronesia (Federated States of)", + "Moldova, The Republic of" => "Moldova, The Republic of", + "Monaco" => "Monaco", + "Mongolia" => "Mongolia", + "Montenegro" => "Montenegro", + "Montserrat" => "Montserrat", + "Morocco" => "Morocco", + "Mozambique" => "Mozambique", + "Myanmar" => "Myanmar", + "Namibia" => "Namibia", + "Nauru" => "Nauru", + "Nepal" => "Nepal", + "Netherlands (Kingdom of the)" => "Netherlands (Kingdom of the)", + "New Caledonia" => "New Caledonia", + "New Zealand" => "New Zealand", + "Nicaragua" => "Nicaragua", + "Niger" => "Niger", + "Nigeria" => "Nigeria", + "Niue" => "Niue", + "Norfolk Island" => "Norfolk Island", + "North Macedonia" => "North Macedonia", + "Northern Mariana Islands" => "Northern Mariana Islands", + "Norway" => "Norway", + "Oman" => "Oman", + "Pakistan" => "Pakistan", + "Palau" => "Palau", + "Palestine, State of" => "Palestine, State of", + "Panama" => "Panama", + "Papua New Guinea" => "Papua New Guinea", + "Paraguay" => "Paraguay", + "Peru" => "Peru", + "Philippines" => "Philippines", + "Pitcairn" => "Pitcairn", + "Poland" => "Poland", + "Portugal" => "Portugal", + "Puerto Rico" => "Puerto Rico", + "Qatar" => "Qatar", + "Reunion" => "Reunion", + "Romania" => "Romania", + "Russian Federation" => "Russian Federation", + "Rwanda" => "Rwanda", + "Saint Barthelemy" => "Saint Barthelemy", + "Saint Helena, Ascension and Tristan da Cunha" => "Saint Helena, Ascension and Tristan da Cunha", + "Saint Kitts and Nevis" => "Saint Kitts and Nevis", + "Saint Lucia" => "Saint Lucia", + "Saint Martin (French part)" => "Saint Martin (French part)", + "Saint Pierre and Miquelon" => "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines" => "Saint Vincent and the Grenadines", + "Samoa" => "Samoa", + "San Marino" => "San Marino", + "Sao Tome and Principe" => "Sao Tome and Principe", + "Saudi Arabia" => "Saudi Arabia", + "Senegal" => "Senegal", + "Serbia" => "Serbia", + "Seychelles" => "Seychelles", + "Sierra Leone" => "Sierra Leone", + "Singapore" => "Singapore", + "Sint Maarten (Dutch part)" => "Sint Maarten (Dutch part)", + "Slovakia" => "Slovakia", + "Slovenia" => "Slovenia", + "Solomon Islands" => "Solomon Islands", + "Somalia" => "Somalia", + "South Africa" => "South Africa", + "South Georgia and the South Sandwich Islands" => "South Georgia and the South Sandwich Islands", + "South Sudan" => "South Sudan", + "Spain" => "Spain", + "Sri Lanka" => "Sri Lanka", + "Sudan" => "Sudan", + "Suriname" => "Suriname", + "Svalbard and Jan Mayen" => "Svalbard and Jan Mayen", + "Sweden" => "Sweden", + "Switzerland" => "Switzerland", + "Syrian Arab Republic" => "Syrian Arab Republic", + "Taiwan (Province of China)" => "Taiwan (Province of China)", + "Tajikistan" => "Tajikistan", + "Tanzania, the United Republic of" => "Tanzania, the United Republic of", + "Thailand" => "Thailand", + "Timor-Leste" => "Timor-Leste", + "Togo" => "Togo", + "Tokelau" => "Tokelau", + "Tonga" => "Tonga", + "Trinidad and Tobago" => "Trinidad and Tobago", + "Tunisia" => "Tunisia", + "Turkiye" => "Turkiye", + "Turkmenistan" => "Turkmenistan", + "Turks and Caicos Islands" => "Turks and Caicos Islands", + "Tuvalu" => "Tuvalu", + "Uganda" => "Uganda", + "Ukraine" => "Ukraine", + "United Arab Emirates" => "United Arab Emirates", + "United Kingdom of Great Britain and Northern Ireland" => "United Kingdom of Great Britain and Northern Ireland", + "United States Minor Outlying Islands" => "United States Minor Outlying Islands", + "United States of America" => "United States of America", + "Uruguay" => "Uruguay", + "Uzbekistan" => "Uzbekistan", + "Vanuatu" => "Vanuatu", + "Venezuela (Bolivarian Republic of)" => "Venezuela (Bolivarian Republic of)", + "Viet Nam" => "Viet Nam", + "Virgin Islands (British)" => "Virgin Islands (British)", + "Virgin Islands (U.S.)" => "Virgin Islands (U.S.)", + "Wallis and Futuna" => "Wallis and Futuna", + "Western Sahara" => "Western Sahara", + "Yemen" => "Yemen", + "Zambia" => "Zambia", + "Zimbabwe" => "Zimbabwe", +); +is( + $CountryList1, + \%LocaleCodesCountryList, + 'countries without OwnCountryList sysconfig setting' ); -for my $Country (@CountryList) { - ok( $CountryExists->{$Country}, "Testing existence of country ($Country)" ); -} - -@CountryList = ( 'Swasiland', 'asdf' ); -for my $Country (@CountryList) { - ok( !$CountryExists->{$Country}, "Testing non-existence of country ($Country)" ); -} # set configuration to small list +my %OwnCode2Name = ( + 'FR' => 'France', + 'NL' => 'Netherlands', + 'DE' => 'Germany' +); + $ConfigObject->Set( Key => 'ReferenceData::OwnCountryList', - Value => { - 'FR' => 'France', - 'NL' => 'Netherlands', - 'DE' => 'Germany' - }, + Value => \%OwnCode2Name, ); -my $OwnCountryExists = $ReferenceDataObject->CountryList; - -@CountryList = ( 'Switzerland', 'United States', 'Japan', 'Sealand' ); -for my $Country (@CountryList) { - ok( !$OwnCountryExists->{$Country}, "OwnCountryList: Testing non-existence of country ($Country)" ); -} - -@CountryList = ( 'France', 'Netherlands', 'Germany' ); -for my $Country (@CountryList) { - ok( $OwnCountryExists->{$Country}, "OwnCountryList: Testing existence of country ($Country)" ); -} +# the parameter Result => 'Code' not passed, +# thus only the values are returned +my $CountryList2 = $ReferenceDataObject->CountryList; +is( + $CountryList2, + { map { $_ => $_ } values %OwnCode2Name }, + 'countries with OwnCountryList system setting' +); -done_testing(); +done_testing;