From 1497075b9ea2c523dcbb8c62d4a9b8a13f1b5043 Mon Sep 17 00:00:00 2001 From: Fredrik Forsmo Date: Mon, 1 Aug 2016 13:21:55 +0200 Subject: [PATCH 1/2] Add tests for `wc_site_is_https` --- tests/unit-tests/util/conditional-functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit-tests/util/conditional-functions.php b/tests/unit-tests/util/conditional-functions.php index 5da4d4142fd..11ea4308f9f 100644 --- a/tests/unit-tests/util/conditional-functions.php +++ b/tests/unit-tests/util/conditional-functions.php @@ -97,6 +97,19 @@ class WC_Tests_Conditional_Functions extends WC_Unit_Test_Case { ); } + /** + * Test wc_site_is_https(). + */ + public function test_wc_site_is_https() { + $this->assertFalse( wc_site_is_https() ); + + add_filter( 'pre_option_home', function () { + return 'https://example.org'; + } ); + + $this->assertTrue( wc_site_is_https() ); + } + /** * Test wc_is_valid_url(). * From 7b01a965076634d7cfbcb482cafc4288c453a3c7 Mon Sep 17 00:00:00 2001 From: Fredrik Forsmo Date: Mon, 1 Aug 2016 14:31:12 +0200 Subject: [PATCH 2/2] Add callback url to `wc_site_is_https` test --- tests/unit-tests/util/conditional-functions.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/unit-tests/util/conditional-functions.php b/tests/unit-tests/util/conditional-functions.php index 11ea4308f9f..07f093a77d0 100644 --- a/tests/unit-tests/util/conditional-functions.php +++ b/tests/unit-tests/util/conditional-functions.php @@ -103,13 +103,20 @@ class WC_Tests_Conditional_Functions extends WC_Unit_Test_Case { public function test_wc_site_is_https() { $this->assertFalse( wc_site_is_https() ); - add_filter( 'pre_option_home', function () { - return 'https://example.org'; - } ); + add_filter( 'pre_option_home', [$this, '_https_url'] ); $this->assertTrue( wc_site_is_https() ); } + /** + * Callback for chaning home url to https. + * + * @return string + */ + public function _https_url() { + return 'https://example.org'; + } + /** * Test wc_is_valid_url(). *