-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Added tests for wp_timezone_choice #5694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pbearne
wants to merge
28
commits into
WordPress:trunk
Choose a base branch
from
pbearne:59941-wp_timezone_choice
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b3ca322
Added tests for wp_timezone_choice
pbearne 56fcd36
Added tests for wp_timezone_choice
pbearne f9643e3
Added tests for wp_timezone_choice
pbearne 42aa0e4
Added tests for wp_timezone_choice
pbearne 667615c
Added tests for wp_timezone_choice
pbearne 3697adf
Merge branch 'WordPress:trunk' into 59941-wp_timezone_choice
pbearne 80e7ac8
Remove redundant city translations in ES locale
pbearne 0b01da3
Merge remote-tracking branch 'origin/59941-wp_timezone_choice' into 5…
pbearne 2201680
Update Spanish locale message translations
pbearne df1d06e
Update wpTimezoneChoice.php
pbearne be19af9
Merge branch 'WordPress:trunk' into 59941-wp_timezone_choice
pbearne 5d205cb
Apply suggestion from @westonruter
pbearne e0fc718
Apply suggestion from @westonruter
pbearne 2266748
Apply suggestion from @westonruter
pbearne 19d7104
Apply suggestion from @westonruter
pbearne 8ab218a
changed to use datasets
cfc4be7
whitespace
08f64e5
whitespace
bde40da
whitespace
ecfdcaa
whitespace
5cb74b2
fix: correct class name casing and improve docblock formatting in tim…
SirLouen 82736cf
Apply suggestions from code review
pbearne fb3fd55
Remove duplicate PHPDoc blocks
t-hamano 0b35c25
Merge branch 'trunk' into 59941-wp_timezone_choice
westonruter 5069002
Use 'functions' as test group for consistency
westonruter 73fad58
Tidy phpdoc
westonruter 828c8af
Merge branch 'trunk' into 59941-wp_timezone_choice
westonruter db4e98a
Merge https://github.com/pbearne/wordpress-develop/pull/183
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| <?php | ||
| return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','messages'=>['Vincennes'=>'Vincennes','Winamac'=>'Winamac','Inuvik'=>'Inuvik','Iqaluit'=>'Iqaluit','Jamaica'=>'Jamaica'],'language'=>'es_ES','x-generator'=>'Poedit 1.8.10']; | ||
| return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','messages'=>['Port Moresby'=>'Puerto Moresby','Arctic'=>'Ártico','Vincennes'=>'Vincennes','Winamac'=>'Winamac','Inuvik'=>'Inuvik','Iqaluit'=>'Iqaluit','Jamaica'=>'Jamaica'],'language'=>'es_ES','x-generator'=>'Poedit 1.8.10']; |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,36 @@ | ||
| # Translation of Continents & Cities in Spanish (Spain) | ||
| # This file is distributed under the same license as the Continents & Cities package. | ||
| # Translation of WordPress - 6.4.x - Development - Continents & Cities in Spanish (Spain) | ||
| # This file is distributed under the same license as the WordPress - 6.4.x - Development - Continents & Cities package. | ||
| msgid "" | ||
| msgstr "" | ||
| "PO-Revision-Date: 2016-10-26 00:01+0200\n" | ||
| "PO-Revision-Date: 2022-10-12 09:13:34+0000\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
| "X-Generator: Poedit 1.8.10\n" | ||
| "Project-Id-Version: Continents & Cities\n" | ||
| "Language: es_ES\n" | ||
| "X-Generator: GlotPress/4.0.0-alpha.11\n" | ||
| "Language: es\n" | ||
| "Project-Id-Version: WordPress - 6.4.x - Development - Continents & Cities\n" | ||
|
|
||
| #: wp-admin/includes/continents-cities.php:140 | ||
| msgid "Vincennes" | ||
| msgstr "Vincennes" | ||
| #: wp-admin/includes/continents-cities.php:539 | ||
| msgid "Port Moresby" | ||
| msgstr "Puerto Moresby" | ||
|
|
||
| #: wp-admin/includes/continents-cities.php:141 | ||
| msgid "Winamac" | ||
| msgstr "Winamac" | ||
| #: wp-admin/includes/continents-cities.php:248 | ||
| msgid "Arctic" | ||
| msgstr "Ártico" | ||
|
|
||
| #: wp-admin/includes/continents-cities.php:149 | ||
| msgid "Iqaluit" | ||
| msgstr "Iqaluit" | ||
|
|
||
| #: wp-admin/includes/continents-cities.php:142 | ||
| #: wp-admin/includes/continents-cities.php:148 | ||
| msgid "Inuvik" | ||
| msgstr "Inuvik" | ||
|
|
||
| #: wp-admin/includes/continents-cities.php:143 | ||
| msgid "Iqaluit" | ||
| msgstr "Iqaluit" | ||
| #: wp-admin/includes/continents-cities.php:146 | ||
| msgid "Vincennes" | ||
| msgstr "Vincennes" | ||
|
|
||
| #: wp-admin/includes/continents-cities.php:144 | ||
| msgid "Jamaica" | ||
| msgstr "Jamaica" | ||
| #: wp-admin/includes/continents-cities.php:147 | ||
| msgid "Winamac" | ||
| msgstr "Winamac" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| <?php | ||
| return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','messages'=>['text directionltr'=>'ltr','<strong>ERROR</strong>: Sorry, that username is not allowed.'=>'<strong>ERROR</strong>: Lo siento, ese nombre de usuario no está permitido.','Invalid parameter.'=>'Parámetro no válido. ','menu location(Current: %s)'=>'(Actual: %s)','menu(Currently set to: %s)'=>'(Actualmente fijado en: %s)','[%1$s] Confirm Action: %2$s'=>'[%1$s] Confirmar la acción: %2$s','[%s] Erasure Request Fulfilled'=>'[%s] Solicitud de borrado completada','[%s] Personal Data Export'=>'[%s] Exportación de datos personales'],'language'=>'es_ES','x-generator'=>'Poedit 2.3']; | ||
| return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','messages'=>['text directionltr'=>'ltr','<strong>ERROR</strong>: Sorry, that username is not allowed.'=>'<strong>ERROR</strong>: Lo siento, ese nombre de usuario no está permitido.','Invalid parameter.'=>'Parámetro no válido. ','menu location(Current: %s)'=>'(Actual: %s)','menu(Currently set to: %s)'=>'(Actualmente fijado en: %s)','[%1$s] Confirm Action: %2$s'=>'[%1$s] Confirmar la acción: %2$s','[%s] Erasure Request Fulfilled'=>'[%s] Solicitud de borrado completada','[%s] Personal Data Export'=>'[%s] Exportación de datos personales', 'Manual Offsets' => 'Compensaciones manuales', 'Select a city' => 'Elige una ciudad' ],'language'=>'es_ES','x-generator'=>'Poedit 2.3']; |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,64 @@ | ||
| # Translation of Development (5.2.x) in Spanish (Spain) | ||
| # This file is distributed under the same license as the Development (5.2.x) package. | ||
| # Translation of WordPress - 6.4.x - Development in Spanish (Spain) | ||
| # This file is distributed under the same license as the WordPress - 6.4.x - Development package. | ||
| msgid "" | ||
| msgstr "" | ||
| "PO-Revision-Date: 2020-07-23 21:12+0300\n" | ||
| "Project-Id-Version: WordPress - 6.4.x - Development\n" | ||
| "POT-Creation-Date: \n" | ||
| "PO-Revision-Date: 2024-02-28 14:31-0500\n" | ||
| "Last-Translator: \n" | ||
| "Language-Team: \n" | ||
| "Language: es\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
| "X-Generator: Poedit 2.3\n" | ||
| "Project-Id-Version: Development (5.2.x)\n" | ||
| "Language: es_ES\n" | ||
| "POT-Creation-Date: \n" | ||
| "Last-Translator: \n" | ||
| "Language-Team: \n" | ||
| "X-Generator: Poedit 3.4.2\n" | ||
|
|
||
| #: wp-includes/functions.php:6635 | ||
| msgid "Manual Offsets" | ||
| msgstr "Compensaciones manuales" | ||
|
|
||
| #: wp-includes/functions.php:6574 | ||
| msgid "Select a city" | ||
| msgstr "Elige una ciudad" | ||
|
|
||
| #. translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. | ||
| #: wp-includes/locale.php:201 | ||
| #: wp-includes/class-wp-locale.php:248 wp-includes/script-loader.php:325 | ||
| #: wp-includes/js/dist/i18n.js:1398 | ||
| #, gp-priority: high | ||
| msgctxt "text direction" | ||
| msgid "ltr" | ||
| msgstr "ltr" | ||
|
|
||
| #: wp-includes/user.php:2132 | ||
| msgid "<strong>ERROR</strong>: Sorry, that username is not allowed." | ||
| msgstr "<strong>ERROR</strong>: Lo siento, ese nombre de usuario no está permitido." | ||
| #: wp-includes/user.php:3357 wp-admin/includes/user.php:202 | ||
| msgid "<strong>Error:</strong> Sorry, that username is not allowed." | ||
| msgstr "<strong>Error</strong>: lo siento, ese nombre de usuario no está permitido." | ||
|
|
||
| #: wp-includes/rest-api/class-wp-rest-request.php:850 | ||
| #: wp-includes/rest-api/class-wp-rest-request.php:916 | ||
| msgid "Invalid parameter." | ||
| msgstr "Parámetro no válido. " | ||
|
|
||
| #. translators: %s: menu name | ||
| #: wp-includes/customize/class-wp-customize-nav-menu-control.php:76 | ||
| #. translators: %s: Menu name. | ||
| #: wp-includes/customize/class-wp-customize-nav-menu-locations-control.php:79 | ||
| msgctxt "menu location" | ||
| msgid "(Current: %s)" | ||
| msgstr "(Actual: %s)" | ||
|
|
||
| #. translators: %s: menu location slug | ||
| #: wp-includes/class-wp-customize-nav-menus.php:340 | ||
| #. translators: %s: Menu location. | ||
| #: wp-includes/class-wp-customize-nav-menus.php:510 | ||
| msgctxt "menu" | ||
| msgid "(Currently set to: %s)" | ||
| msgstr "(Actualmente fijado en: %s)" | ||
|
|
||
| #. translators: Privacy data request subject. 1: Site name, 2: Name of the action | ||
| #: wp-includes/user.php:3445 | ||
| #. translators: Confirm privacy data request notification email subject. 1: | ||
| #. Site title, 2: Name of the action. | ||
| #: wp-includes/user.php:4705 | ||
| msgid "[%1$s] Confirm Action: %2$s" | ||
| msgstr "[%1$s] Confirmar la acción: %2$s" | ||
|
|
||
| #. translators: %s: Site name. | ||
| #: wp-includes/user.php:3175 | ||
| #. translators: Erasure request fulfilled notification email subject. %s: Site | ||
| #. title. | ||
| #: wp-includes/user.php:4299 | ||
| msgid "[%s] Erasure Request Fulfilled" | ||
| msgstr "[%s] Solicitud de borrado completada" | ||
|
|
||
| #: wp-admin/includes/file.php:2415 | ||
| msgid "[%s] Personal Data Export" | ||
| msgstr "[%s] Exportación de datos personales" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Tests for the wp_timezone_choice function. | ||
| * | ||
| * @group functions | ||
| * | ||
| * @covers ::wp_timezone_choice | ||
| */ | ||
| class Tests_Functions_WpTimezoneChoice extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * Tears down. | ||
| */ | ||
| public function tear_down() { | ||
| restore_current_locale(); | ||
| parent::tear_down(); | ||
| } | ||
|
|
||
| /** | ||
| * Tests default values. | ||
| * | ||
| * @ticket 59941 | ||
| * @dataProvider data_wp_timezone_choice | ||
| * | ||
| * @param string $expected Expected string HTML fragment. | ||
| */ | ||
| public function test_wp_timezone_choice( $expected ) { | ||
| $timezone_list = wp_timezone_choice( '' ); | ||
| $this->assertStringContainsString( $expected, $timezone_list ); | ||
| } | ||
|
|
||
| /** | ||
| * Gets data sets for test_wp_timezone_choice. | ||
| * | ||
| * @return array<string, string[]> | ||
| */ | ||
| public function data_wp_timezone_choice(): array { | ||
| return array( | ||
| 'placeholder option' => array( '<option selected="selected" value="">Select a city</option>' ), | ||
| 'city in Americas' => array( '<option value="America/Los_Angeles">Los Angeles</option>' ), | ||
| 'deprecated timezone' => array( '<option value="Pacific/Honolulu">Honolulu</option>' ), | ||
| 'manual offset example' => array( '<option value="UTC-8">UTC-8</option>' ), | ||
| 'UTC option' => array( '<option value="UTC">UTC</option>' ), | ||
| 'continent example' => array( '<option value="Africa/Johannesburg">Johannesburg</option>' ), | ||
| 'city example' => array( '<option value="Asia/Kuala_Lumpur">Kuala Lumpur</option>' ), | ||
| 'city with sub-city' => array( '<option value="America/Argentina/Buenos_Aires">Argentina - Buenos Aires</option>' ), | ||
| 'translated city name appears' => array( '<option value="Pacific/Port_Moresby">Port Moresby</option>' ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests zones are selected from the list. | ||
| * | ||
| * @ticket 59941 | ||
| * @dataProvider data_wp_timezone_choice_selected | ||
| * | ||
| * @param string $selected_zone The timezone to select. | ||
| * @param string $expected Expected string HTML fragment. | ||
| */ | ||
| public function test_wp_timezone_choice_selected( $selected_zone, $expected ) { | ||
| $actual = wp_timezone_choice( $selected_zone ); | ||
| $this->assertStringContainsString( $expected, $actual ); | ||
| } | ||
|
|
||
pbearne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Gets data sets for test_wp_timezone_choice_selected. | ||
| * | ||
| * @return array<string, string[]> | ||
| */ | ||
| public function data_wp_timezone_choice_selected(): array { | ||
| return array( | ||
| 'city from the list' => array( | ||
| 'America/Los_Angeles', | ||
| '<option selected="selected" value="America/Los_Angeles">Los Angeles</option>', | ||
| ), | ||
| 'deprecated but valid timezone string' => array( | ||
| 'Pacific/Auckland', | ||
| '<option selected="selected" value="Pacific/Auckland">Auckland</option>', | ||
| ), | ||
| 'UTC' => array( | ||
| 'UTC', | ||
| '<option selected="selected" value="UTC">UTC</option>', | ||
| ), | ||
| 'manual UTC offset' => array( | ||
| 'UTC+10', | ||
| '<option selected="selected" value="UTC+10">UTC+10</option>', | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests passing in the locale. | ||
| * | ||
| * @ticket 59941 | ||
| * @dataProvider data_wp_timezone_choice_es | ||
| * | ||
| * @param string $expected Expected string HTML fragment. | ||
| */ | ||
| public function test_wp_timezone_choice_es( $expected ) { | ||
| $timezone_list = wp_timezone_choice( '', 'es_ES' ); | ||
| $this->assertStringContainsString( $expected, $timezone_list ); | ||
| } | ||
|
|
||
| /** | ||
| * Gets data sets for test_wp_timezone_choice_es. | ||
| * | ||
| * @return array<string, string[]> | ||
| */ | ||
| public function data_wp_timezone_choice_es(): array { | ||
| return array( | ||
| 'placeholder remains in English (no translation override passed)' => array( '<option selected="selected" value="">Select a city</option>' ), | ||
| 'spanish city translation' => array( '<option value="Pacific/Port_Moresby">Puerto Moresby</option>' ), | ||
| 'spanish optgroup Arctic' => array( '<optgroup label="Ártico">' ), | ||
| 'spanish optgroup Manual Offsets untranslated' => array( '<optgroup label="Manual Offsets">' ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Tests setting the locale globally. | ||
| * | ||
| * @ticket 59941 | ||
| * @dataProvider data_wp_timezone_choice_es_set | ||
| * | ||
| * @param string $expected Expected string HTML fragment. | ||
| */ | ||
| public function test_wp_timezone_choice_es_set( $expected ) { | ||
| switch_to_locale( 'es_ES' ); | ||
| $timezone_list = wp_timezone_choice( '' ); | ||
| $this->assertStringContainsString( $expected, $timezone_list ); | ||
| } | ||
|
|
||
| /** | ||
| * Gets data sets for test_wp_timezone_choice_es_set. | ||
| * | ||
| * @return array<string, string[]> | ||
| */ | ||
| public function data_wp_timezone_choice_es_set(): array { | ||
| return array( | ||
| 'placeholder in Spanish' => array( '<option selected="selected" value="">Elige una ciudad</option>' ), | ||
| 'spanish city translation' => array( '<option value="Pacific/Port_Moresby">Puerto Moresby</option>' ), | ||
| 'spanish optgroup Arctic' => array( '<optgroup label="Ártico">' ), | ||
| 'spanish optgroup Manual Offsets' => array( '<optgroup label="Compensaciones manuales">' ), | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.