File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -181,11 +181,21 @@ function test_add_schema_non_ssl() {
181181 * Regression: operator-precedence bug caused https: to be returned bare instead of https://example.org/...
182182 */
183183 function test_add_schema_ssl () {
184- $ _SERVER ['HTTPS ' ] = 'on ' ;
185- $ result = $ this ->add_schema ( '//example.org/image.jpg ' );
186- unset( $ _SERVER ['HTTPS ' ] );
187-
188- $ this ->assertEquals ( 'https://example.org/image.jpg ' , $ result );
184+ $ had_https = array_key_exists ( 'HTTPS ' , $ _SERVER );
185+ $ previous_https = $ had_https ? $ _SERVER ['HTTPS ' ] : null ;
186+
187+ try {
188+ $ _SERVER ['HTTPS ' ] = 'on ' ;
189+ $ result = $ this ->add_schema ( '//example.org/image.jpg ' );
190+
191+ $ this ->assertEquals ( 'https://example.org/image.jpg ' , $ result );
192+ } finally {
193+ if ( $ had_https ) {
194+ $ _SERVER ['HTTPS ' ] = $ previous_https ;
195+ } else {
196+ unset( $ _SERVER ['HTTPS ' ] );
197+ }
198+ }
189199 }
190200
191201 /**
You can’t perform that action at this time.
0 commit comments