Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/phpunit/tests/functions/forceSslAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public function set_up() {
force_ssl_admin( false );
}

public function tear_down() {
force_ssl_admin( false );

parent::tear_down();
}

/**
* Tests that force_ssl_admin() returns expected values based on various inputs.
*
Expand Down
17 changes: 16 additions & 1 deletion tests/phpunit/tests/functions/wpTimezoneChoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@
class Tests_Functions_WpTimezoneChoice extends WP_UnitTestCase {

/**
* Restores the current locale after each test runs.
* Whether timezone translations need to be restored after the test.
*
* @var bool
*/
private $restore_timezone_translations = false;

/**
* Restores the current locale and timezone translations after each test runs.
*/
public function tear_down(): void {
restore_current_locale();

if ( $this->restore_timezone_translations ) {
// Synchronize the function's static locale tracking with the restored translations.
wp_timezone_choice( '', get_locale() );
}

parent::tear_down();
}

Expand Down Expand Up @@ -98,7 +111,8 @@
* @param string $expected Expected string HTML fragment.
*/
public function test_wp_timezone_choice_es( string $expected ): void {
$this->restore_timezone_translations = true;
$timezone_list = wp_timezone_choice( '', 'es_ES' );

Check warning on line 115 in tests/phpunit/tests/functions/wpTimezoneChoice.php

View workflow job for this annotation

GitHub Actions / Coding standards / PHP checks

Equals sign not aligned with surrounding assignments; expected 23 spaces but found 1 space
$this->assertStringContainsString( $expected, $timezone_list );
}

Expand All @@ -125,6 +139,7 @@
* @param string $expected Expected string HTML fragment.
*/
public function test_wp_timezone_choice_es_set( string $expected ): void {
$this->restore_timezone_translations = true;
switch_to_locale( 'es_ES' );
$timezone_list = wp_timezone_choice( '' );
$this->assertStringContainsString( $expected, $timezone_list );
Expand Down
Loading