diff --git a/tests/phpunit/tests/functions/forceSslAdmin.php b/tests/phpunit/tests/functions/forceSslAdmin.php new file mode 100644 index 0000000000000..4371e6cdd8e8d --- /dev/null +++ b/tests/phpunit/tests/functions/forceSslAdmin.php @@ -0,0 +1,55 @@ + array( null, false, false ), + 'first_call_true' => array( true, false, true ), + 'first_call_false' => array( false, false, false ), + 'first_call_non_empty_string' => array( 'some string', false, true ), + 'empty_string' => array( '', false, false ), + 'first_call_integer_1' => array( 1, false, true ), + 'integer_0' => array( 0, false, false ), + ); + } + + /** + * Tests that force_ssl_admin returns expected values based on various inputs. + * + * @dataProvider data_should_return_expected_value_when_various_inputs_are_passed + * + * @param mixed $input The input value to test. + * @param bool $expectedFirstCall The expected result for the first call. + * @param bool $expectedSubsequentCall The expected result for subsequent calls. + */ + public function test_should_return_expected_value_when_various_inputs_are_passed( $input, $expectedFirstCall, $expectedSubsequentCall ) { + $this->assertSame( $expectedFirstCall, force_ssl_admin( $input ), 'First call did not return expected value' ); + + // Call again to check subsequent behavior + $this->assertSame( $expectedSubsequentCall, force_ssl_admin( $input ), 'Subsequent call did not return expected value' ); + } +}