Completed
Pull Request — master (#15)
by Marin
01:29
created

testWithHttpUrlAndHttpsOnAndDifferentDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
class WpHydraReplaceDomainTest extends WP_UnitTestCase {
4
5
	public function setUp() {
6
		$this->wp_hydra = $this->getMockBuilder('WP_Hydra_Exposed_RD')->setMethods(array('is_ssl'))->getMock();
7
	}
8
9
	public function tearDown() {
10
		unset( $this->wp_hydra );
11
	}
12
13
	/**
14
	 * @covers WP_Hydra::replace_domain
15
	 */
16 View Code Duplication
	public function testWithHttpUrlAndHttpsOff() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
		$this->wp_hydra->expects($this->any())
18
			->method('is_ssl')
19
			->will($this->returnValue(false));
20
21
		$url = 'http://example.com/';
22
		$result = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' );
23
		$this->assertSame( $url, $result );
24
	}
25
26
	/**
27
	 * @covers WP_Hydra::replace_domain
28
	 */
29 View Code Duplication
	public function testWithHttpUrlAndHttpsOn() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
		$this->wp_hydra->expects($this->any())
31
			->method('is_ssl')
32
			->will($this->returnValue(true));
33
34
		$url = 'http://example.com/';
35
		$expected = 'https://example.com/';
36
		$actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' );
37
		$this->assertSame( $expected, $actual );
38
	}
39
40
	/**
41
	 * @covers WP_Hydra::replace_domain
42
	 */
43 View Code Duplication
	public function testWithHttpsUrlAndHttpsOff() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
		$this->wp_hydra->expects($this->any())
45
			->method('is_ssl')
46
			->will($this->returnValue(false));
47
48
		$url = 'https://example.com/';
49
		$expected = 'http://example.com/';
50
		$actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' );
51
		$this->assertSame( $expected, $actual );
52
	}
53
54
	/**
55
	 * @covers WP_Hydra::replace_domain
56
	 */
57 View Code Duplication
	public function testWithHttpsUrlAndHttpsOn() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
		$this->wp_hydra->expects($this->any())
59
			->method('is_ssl')
60
			->will($this->returnValue(true));
61
62
		$url = 'https://example.com/';
63
		$actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' );
64
		$this->assertSame( $url, $actual );
65
	}
66
67
	/**
68
	 * @covers WP_Hydra::replace_domain
69
	 */
70 View Code Duplication
	public function testWithHttpUrlAndHttpsOffAndDifferentDomain() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
		$this->wp_hydra->expects($this->any())
72
			->method('is_ssl')
73
			->will($this->returnValue(false));
74
75
		$url = 'http://example.com/';
76
		$expected = 'http://foobar.com/';
77
		$result = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' );
78
		$this->assertSame( $expected, $result );
79
	}
80
81
	/**
82
	 * @covers WP_Hydra::replace_domain
83
	 */
84 View Code Duplication
	public function testWithHttpUrlAndHttpsOnAndDifferentDomain() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
		$this->wp_hydra->expects($this->any())
86
			->method('is_ssl')
87
			->will($this->returnValue(true));
88
89
		$url = 'http://example.com/';
90
		$expected = 'https://foobar.com/';
91
		$actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' );
92
		$this->assertSame( $expected, $actual );
93
	}
94
95
	/**
96
	 * @covers WP_Hydra::replace_domain
97
	 */
98 View Code Duplication
	public function testWithHttpsUrlAndHttpsOffAndDifferentDomain() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
		$this->wp_hydra->expects($this->any())
100
			->method('is_ssl')
101
			->will($this->returnValue(false));
102
103
		$url = 'https://example.com/';
104
		$expected = 'http://foobar.com/';
105
		$actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' );
106
		$this->assertSame( $expected, $actual );
107
	}
108
109
	/**
110
	 * @covers WP_Hydra::replace_domain
111
	 */
112 View Code Duplication
	public function testWithHttpsUrlAndHttpsOnAndDifferentDomain() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
		$this->wp_hydra->expects($this->any())
114
			->method('is_ssl')
115
			->will($this->returnValue(true));
116
117
		$url = 'https://example.com/';
118
		$expected = 'https://foobar.com/';
119
		$actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' );
120
		$this->assertSame( $expected, $actual );
121
	}
122
123
}
124
125
class WP_Hydra_Exposed_RD extends WP_Hydra {
126
	public function replace_domain_exposed( $url, $original_domain, $current_domain ) {
127
		return $this->replace_domain( $url, $original_domain, $current_domain );
128
	}
129
}