Completed
Pull Request — master (#15)
by Marin
03:51 queued 02:28
created

WpHydraIsSslTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A tearDown() 0 3 1
A testWithSslDisabled() 0 7 1
A testWithSslEnabled() 0 7 1
1
<?php
2
/**
3
 * Contains tests for WP_Hydra::is_ssl()
4
 *
5
 * @package wp-hydra
6
 */
7
8
/**
9
 * Tests for WP_Hydra::is_ssl()
10
 */
11
class WpHydraIsSslTest extends WP_UnitTestCase {
12
	/**
13
	 * Test setup
14
	 */
15
	public function setUp() {
16
		$this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->setMethods( null )->getMock();
17
	}
18
19
	/**
20
	 * Test teardown
21
	 */
22
	public function tearDown() {
23
		unset( $this->wp_hydra );
24
	}
25
26
	/**
27
	 * Test when SSL is disabled.
28
	 *
29
	 * @covers WP_Hydra::is_ssl
30
	 */
31
	public function testWithSslDisabled() {
32
		$_SERVER['HTTPS'] = 0;
33
		$this->assertFalse( $this->wp_hydra->is_ssl() );
34
35
		$_SERVER['HTTPS'] = false;
36
		$this->assertFalse( $this->wp_hydra->is_ssl() );
37
	}
38
39
	/**
40
	 * Test when SSL is enabled.
41
	 *
42
	 * @covers WP_Hydra::is_ssl
43
	 */
44
	public function testWithSslEnabled() {
45
		$_SERVER['HTTPS'] = 1;
46
		$this->assertTrue( $this->wp_hydra->is_ssl() );
47
48
		$_SERVER['HTTPS'] = 'on';
49
		$this->assertTrue( $this->wp_hydra->is_ssl() );
50
	}
51
52
}
53