Make WordPress Core

Changeset 1000 in tests for trunk/tests/url.php


Ignore:
Timestamp:
08/31/2012 05:46:30 PM (14 years ago)
Author:
ryan
Message:

Tests for home_url() and network_home_url() to make sure the is_ssl() state is discarded when in the admin. see #WP20759

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/url.php

    r996 r1000  
    132132        }
    133133
     134        function test_home_url_from_admin() {
     135                $screen = get_current_screen();
     136
     137                // Pretend to be in the site admin
     138                set_current_screen( 'dashboard' );
     139                $home = get_option('home');
     140
     141                // home_url() should return http when in the admin
     142                $_SERVER['HTTPS'] = 'on';
     143                $this->assertEquals( $home, home_url() );
     144
     145                $_SERVER['HTTPS'] = 'off';
     146                $this->assertEquals( $home, home_url() );
     147
     148                // If not in the admin, is_ssl() should determine the scheme
     149                set_current_screen( 'front' );
     150                $this->assertEquals( $home, home_url() );
     151                $_SERVER['HTTPS'] = 'on';
     152                $home = str_replace('http://', 'https://', $home);
     153                $this->assertEquals( $home, home_url() );
     154        }
     155
     156        function test_network_home_url_from_admin() {
     157                $screen = get_current_screen();
     158
     159                // Pretend to be in the site admin
     160                set_current_screen( 'dashboard' );
     161                $home = network_home_url();
     162
     163                // home_url() should return http when in the admin
     164                $this->assertEquals( 0, strpos( $home, 'http://') );
     165                $_SERVER['HTTPS'] = 'on';
     166                $this->assertEquals( $home, network_home_url() );
     167
     168                $_SERVER['HTTPS'] = 'off';
     169                $this->assertEquals( $home, network_home_url() );
     170
     171                // If not in the admin, is_ssl() should determine the scheme
     172                set_current_screen( 'front' );
     173                $this->assertEquals( $home, network_home_url() );
     174                $_SERVER['HTTPS'] = 'on';
     175                $home = str_replace('http://', 'https://', $home);
     176                $this->assertEquals( $home, network_home_url() );
     177        }
     178
    134179        function test_set_url_scheme() {
    135180                if ( ! function_exists( 'set_url_scheme' ) )
Note: See TracChangeset for help on using the changeset viewer.