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

WpHydraSetupUploadDirTest::wp_hydra_domain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Contains tests for WP_Hydra::setup_upload_dir()
4
 *
5
 * @package wp-hydra
6
 */
7
8
/**
9
 * Tests for WP_Hydra::setup_upload_dir()
10
 */
11
class WpHydraSetupUploadDirTest extends WP_UnitTestCase {
12
	/**
13
	 * Test setup
14
	 */
15
	public function setUp() {
16
		$this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->disableOriginalConstructor()->setMethods( null )->getMock();
17
18
		add_filter( 'wp_hydra_domain', array( $this, 'wp_hydra_domain' ) );
19
	}
20
21
	/**
22
	 * Test teardown
23
	 */
24
	public function tearDown() {
25
		remove_filter( 'wp_hydra_domain', array( $this, 'wp_hydra_domain' ) );
26
27
		unset( $this->wp_hydra );
28
	}
29
30
	/**
31
	 * Test the filter on URLs.
32
	 *
33
	 * @covers WP_Hydra::setup_upload_dir
34
	 */
35 View Code Duplication
	public function testFilterOnUrls() {
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...
36
		$upload_dir = array(
37
			'url'     => 'example.com',
38
			'baseurl' => 'example.com',
39
		);
40
		$expected   = array(
41
			'url'     => 'foobar.com',
42
			'baseurl' => 'foobar.com',
43
		);
44
		$actual     = $this->wp_hydra->setup_upload_dir( $upload_dir );
45
		$this->assertSame( $expected, $actual );
46
	}
47
48
	/**
49
	 * Test the filter on another field.
50
	 *
51
	 * @covers WP_Hydra::setup_upload_dir
52
	 */
53 View Code Duplication
	public function testFilterOnSomethingElse() {
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
		$upload_dir = array(
55
			'url'     => 'foobar.com',
56
			'baseurl' => 'foobar.com',
57
			'foobar'  => 'example.com',
58
		);
59
		$expected   = $upload_dir;
60
		$actual     = $this->wp_hydra->setup_upload_dir( $upload_dir );
61
		$this->assertSame( $expected, $actual );
62
	}
63
64
	/**
65
	 * Used for hooking on the wp_hydra_domain filter.
66
	 *
67
	 * @param string $domain The domain.
68
	 * @return string A different domain domain.
69
	 */
70
	public function wp_hydra_domain( $domain ) {
71
		return 'foobar.com';
72
	}
73
74
}
75