Changeset 60137
- Timestamp:
- 04/07/2025 11:13:03 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/forceSslAdmin.php
r59830 r60137 2 2 /** 3 3 * Test cases for the `force_ssl_admin()` function. 4 *5 * @package WordPress\UnitTests6 4 * 7 5 * @since 6.8.0 … … 13 11 class Tests_Functions_ForceSslAdmin extends WP_UnitTestCase { 14 12 15 public function set_up() : void{13 public function set_up() { 16 14 parent::set_up(); 17 // Reset the static variable before each test15 // Reset the `$forced` static variable before each test. 18 16 force_ssl_admin( false ); 19 17 } 20 18 21 19 /** 22 * Data provider for testing force_ssl_admin.20 * Tests that force_ssl_admin() returns expected values based on various inputs. 23 21 * 24 * Provides various inputs and expected outcomes for the function. 22 * @dataProvider data_force_ssl_admin 23 * 24 * @param mixed $input The input value to test. 25 * @param bool $expected The expected result for subsequent calls. 26 */ 27 public function test_force_ssl_admin( $input, $expected ) { 28 // The first call always returns the previous value. 29 $this->assertFalse( force_ssl_admin( $input ), 'First call did not return the expected value' ); 30 31 // Call again to check subsequent behavior. 32 $this->assertSame( $expected, force_ssl_admin( $input ), 'Subsequent call did not return the expected value' ); 33 } 34 35 /** 36 * Data provider for testing force_ssl_admin(). 25 37 * 26 38 * @return array[] 27 39 */ 28 public function data_ should_return_expected_value_when_various_inputs_are_passed() {40 public function data_force_ssl_admin() { 29 41 return array( 30 'default' => array( null, false, false ),31 ' first_call_true' => array( true, false, true ),32 'f irst_call_false' => array( false,false, false ),33 ' first_call_non_empty_string' => array( 'some string', false, true ),34 'empty _string' => array( '', false, false ),35 ' first_call_integer_1' => array( 1, false, true ),36 'integer _0' => array( 0, false, false ),42 'default' => array( null, false ), 43 'true' => array( true, true ), 44 'false' => array( false, false ), 45 'non-empty string' => array( 'some string', true ), 46 'empty string' => array( '', false ), 47 'integer 1' => array( 1, true ), 48 'integer 0' => array( 0, false ), 37 49 ); 38 50 } 39 40 /**41 * Tests that force_ssl_admin returns expected values based on various inputs.42 *43 * @dataProvider data_should_return_expected_value_when_various_inputs_are_passed44 *45 * @param mixed $input The input value to test.46 * @param bool $expected_first_call The expected result for the first call.47 * @param bool $expected_subsequent_call The expected result for subsequent calls.48 */49 public function test_should_return_expected_value_when_various_inputs_are_passed( $input, $expected_first_call, $expected_subsequent_call ) {50 $this->assertSame( $expected_first_call, force_ssl_admin( $input ), 'First call did not return expected value' );51 52 // Call again to check subsequent behavior53 $this->assertSame( $expected_subsequent_call, force_ssl_admin( $input ), 'Subsequent call did not return expected value' );54 }55 51 }
Note: See TracChangeset
for help on using the changeset viewer.