| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * @group canonical |
| | 5 | * @group rewrite |
| | 6 | * @group query |
| | 7 | */ |
| | 8 | class Tests_Canonical_Force_SSL extends WP_Canonical_UnitTestCase { |
| | 9 | |
| | 10 | function setUp() { |
| | 11 | parent::setUp(); |
| | 12 | define('FORCE_SSL', true); |
| | 13 | |
| | 14 | $this->http = home_url('sample-page/', 'http'); |
| | 15 | $this->https = home_url('sample-page/', 'https'); |
| | 16 | } |
| | 17 | |
| | 18 | public function set_https($url) { |
| | 19 | return set_url_scheme($url, 'https'); |
| | 20 | } |
| | 21 | |
| | 22 | /** |
| | 23 | * @ticket 27954 |
| | 24 | */ |
| | 25 | public function test_http_request_with_http_home() { |
| | 26 | $redirect = redirect_canonical($this->http, FALSE); |
| | 27 | $this->assertEquals($redirect, $this->https); |
| | 28 | } |
| | 29 | |
| | 30 | /** |
| | 31 | * @ticket 27954 |
| | 32 | */ |
| | 33 | public function test_https_request_with_http_home() { |
| | 34 | $redirect = redirect_canonical($this->https, FALSE); |
| | 35 | $this->assertEquals($redirect, FALSE); // No redirect |
| | 36 | } |
| | 37 | |
| | 38 | /** |
| | 39 | * @ticket 27954 |
| | 40 | */ |
| | 41 | public function test_http_request_with_https_home() { |
| | 42 | add_filter('home_url', array($this, 'set_https')); |
| | 43 | $redirect = redirect_canonical($this->http, FALSE); |
| | 44 | $this->assertEquals($redirect, $this->https); |
| | 45 | remove_filter('home_url', array($this, 'set_https')); |
| | 46 | } |
| | 47 | |
| | 48 | /** |
| | 49 | * @ticket 27954 |
| | 50 | */ |
| | 51 | public function test_https_request_with_https_home() { |
| | 52 | add_filter('home_url', array($this, 'set_https')); |
| | 53 | $redirect = redirect_canonical($this->https, FALSE); |
| | 54 | $this->assertEquals($redirect, FALSE); // No redirect |
| | 55 | remove_filter('home_url', array($this, 'set_https')); |
| | 56 | } |
| | 57 | |
| | 58 | } |