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

WpHydraSetupContentTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Contains tests for WP_Hydra::setup_content()
4
 *
5
 * @package wp-hydra
6
 */
7
8
/**
9
 * Tests for WP_Hydra::setup_content()
10
 */
11
class WpHydraSetupContentTest extends WP_UnitTestCase {
12
	/**
13
	 * Test setup
14
	 */
15
	public function setUp() {
16
		$this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->disableOriginalConstructor()->setMethods( array( 'setup_domain' ) )->getMock();
17
18
		$this->domain = 'https://foobar.com';
19
20
		$this->wp_hydra->expects( $this->any() )
21
			->method( 'setup_domain' )
22
			->will( $this->returnValue( $this->domain ) );
23
24
		remove_all_filters( 'option_home', 1 );
25
	}
26
27
	/**
28
	 * Test teardown
29
	 */
30
	public function tearDown() {
31
		unset( $this->wp_hydra );
32
		unset( $this->domain );
33
	}
34
35
	/**
36
	 * Test occurences in the beginning.
37
	 *
38
	 * @covers WP_Hydra::setup_content
39
	 */
40 View Code Duplication
	public function testOccurencesInTheBeginning() {
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...
41
		$content  = 'https://example.org/ foo bar ';
42
		$expected = $this->domain . '/ foo bar ';
43
		$actual   = $this->wp_hydra->setup_content( $content );
44
45
		$this->assertSame( $expected, $actual );
46
	}
47
48
	/**
49
	 * Test occurences in the middle.
50
	 *
51
	 * @covers WP_Hydra::setup_content
52
	 */
53 View Code Duplication
	public function testOccurencesInTheMiddle() {
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...
54
		$content  = 'helloWorld https://example.org/ foo bar ';
55
		$expected = 'helloWorld ' . $this->domain . '/ foo bar ';
56
		$actual   = $this->wp_hydra->setup_content( $content );
57
58
		$this->assertSame( $expected, $actual );
59
	}
60
61
	/**
62
	 * Test occurences in the end.
63
	 *
64
	 * @covers WP_Hydra::setup_content
65
	 */
66 View Code Duplication
	public function testOccurencesInTheEnd() {
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...
67
		$content  = 'helloWorld https://example.org/';
68
		$expected = 'helloWorld ' . $this->domain . '/';
69
		$actual   = $this->wp_hydra->setup_content( $content );
70
71
		$this->assertSame( $expected, $actual );
72
	}
73
74
	/**
75
	 * Test multiple occurences.
76
	 *
77
	 * @covers WP_Hydra::setup_content
78
	 */
79
	public function testMultipleOccurences() {
80
		$content  = 'https://example.org/ helloWorld https://example.org/ foo bar https://example.org/';
81
		$expected = $this->domain . '/ helloWorld ' . $this->domain . '/ foo bar ' . $this->domain . '/';
82
		$actual   = $this->wp_hydra->setup_content( $content );
83
84
		$this->assertSame( $expected, $actual );
85
	}
86
87
	/**
88
	 * Test occurences in an image.
89
	 *
90
	 * @covers WP_Hydra::setup_content
91
	 */
92 View Code Duplication
	public function testOccurencesInAnImage() {
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...
93
		$content  = '<img src="https://example.org/wp-content/uploads/2012/12/test.jpg" width="640" height="480" alt="" />';
94
		$expected = '<img src="' . $this->domain . '/wp-content/uploads/2012/12/test.jpg" width="640" height="480" alt="" />';
95
		$actual   = $this->wp_hydra->setup_content( $content );
96
97
		$this->assertSame( $expected, $actual );
98
	}
99
100
	/**
101
	 * Test occurences in a link.
102
	 *
103
	 * @covers WP_Hydra::setup_content
104
	 */
105 View Code Duplication
	public function testOccurencesInALink() {
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...
106
		$content  = '<a href="https://example.org/foo/bar/">Test</a>';
107
		$expected = '<a href="' . $this->domain . '/foo/bar/">Test</a>';
108
		$actual   = $this->wp_hydra->setup_content( $content );
109
110
		$this->assertSame( $expected, $actual );
111
	}
112
113
}
114