Make WordPress Core

Ticket #20759: 20759-ut.diff

File 20759-ut.diff, 1.1 KB (added by ryan, 12 years ago)

unit tests for https in home

  • tests/url.php

     
    152152                $home = str_replace('http://', 'https://', $home);
    153153                $this->assertEquals( $home, home_url() );
    154154
     155
     156                // Test with https in home
     157                update_option( 'home', set_url_scheme( $home, 'https' ) );
     158
     159                // Pretend to be in the site admin
     160                set_current_screen( 'dashboard' );
     161                $home = get_option('home');
     162
     163                // home_url() should return whatever scheme is set in the home option when in the admin
     164                $_SERVER['HTTPS'] = 'on';
     165                $this->assertEquals( $home, home_url() );
     166
     167                $_SERVER['HTTPS'] = 'off';
     168                $this->assertEquals( $home, home_url() );
     169
     170                // If not in the admin, is_ssl() should determine the scheme unless https hard-coded in home
     171                set_current_screen( 'front' );
     172                $this->assertEquals( $home, home_url() );
     173                $_SERVER['HTTPS'] = 'on';
     174                $this->assertEquals( $home, home_url() );
     175                $_SERVER['HTTPS'] = 'off';
     176                $this->assertEquals( $home, home_url() );
     177
     178                update_option( 'home', set_url_scheme( $home, 'http' ) );
     179
    155180                $GLOBALS['current_screen'] = $screen;
    156181        }
    157182