@@ -14,12 +14,12 @@ |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | // Exit if accessed directly. |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if (!defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Load main class. |
22 | -include_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-wp-hydra.php' ); |
|
22 | +include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'class-wp-hydra.php'); |
|
23 | 23 | |
24 | 24 | // initialize WP Hydra - Polycephaly FTW! |
25 | 25 | global $wp_hydra; |
@@ -18,24 +18,24 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | // Modify domain where necessary. |
21 | - add_filter( 'option_blogname', array( $this, 'setup_domain' ), 1 ); |
|
22 | - add_filter( 'option_siteurl', array( $this, 'setup_domain' ), 1 ); |
|
23 | - add_filter( 'option_home', array( $this, 'setup_domain' ), 1 ); |
|
24 | - add_filter( 'stylesheet_uri', array( $this, 'setup_domain' ), 1 ); |
|
25 | - add_filter( 'stylesheet_directory_uri', array( $this, 'setup_domain' ), 1 ); |
|
26 | - add_filter( 'template_directory_uri', array( $this, 'setup_domain' ), 1 ); |
|
27 | - add_filter( 'plugins_url', array( $this, 'setup_domain' ), 1 ); |
|
21 | + add_filter('option_blogname', array($this, 'setup_domain'), 1); |
|
22 | + add_filter('option_siteurl', array($this, 'setup_domain'), 1); |
|
23 | + add_filter('option_home', array($this, 'setup_domain'), 1); |
|
24 | + add_filter('stylesheet_uri', array($this, 'setup_domain'), 1); |
|
25 | + add_filter('stylesheet_directory_uri', array($this, 'setup_domain'), 1); |
|
26 | + add_filter('template_directory_uri', array($this, 'setup_domain'), 1); |
|
27 | + add_filter('plugins_url', array($this, 'setup_domain'), 1); |
|
28 | 28 | |
29 | 29 | // Replace various occurences. |
30 | - add_filter( 'the_content', array( $this, 'setup_content' ) ); // In oost content. |
|
31 | - add_filter( 'widget_text', array( $this, 'setup_content' ) ); // In Widget text. |
|
32 | - add_filter( 'upload_dir', array( $this, 'setup_upload_dir' ) ); // In wp_upload_dir(). |
|
30 | + add_filter('the_content', array($this, 'setup_content')); // In oost content. |
|
31 | + add_filter('widget_text', array($this, 'setup_content')); // In Widget text. |
|
32 | + add_filter('upload_dir', array($this, 'setup_upload_dir')); // In wp_upload_dir(). |
|
33 | 33 | |
34 | 34 | // Allow developers to support multiple domains in fields that contain only a site URL. |
35 | - add_filter( 'wp_hydra_domain', array( $this, 'setup_domain' ) ); |
|
35 | + add_filter('wp_hydra_domain', array($this, 'setup_domain')); |
|
36 | 36 | |
37 | 37 | // Allow developers to support URLs with multiple domains in their content. |
38 | - add_filter( 'wp_hydra_content', array( $this, 'setup_content' ) ); |
|
38 | + add_filter('wp_hydra_content', array($this, 'setup_content')); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @param string $url The current URL. |
47 | 47 | * @return string $url The URL with the (maybe) replaced domain. |
48 | 48 | */ |
49 | - public function setup_domain( $url ) { |
|
49 | + public function setup_domain($url) { |
|
50 | 50 | // Parse current URL. |
51 | - $original_domain_parts = parse_url( $url ); |
|
51 | + $original_domain_parts = parse_url($url); |
|
52 | 52 | |
53 | 53 | // If unable to retrieve the host, skip. |
54 | - if ( empty( $original_domain_parts['host'] ) || ! isset( $_SERVER['HTTP_HOST'] ) ) { |
|
54 | + if (empty($original_domain_parts['host']) || !isset($_SERVER['HTTP_HOST'])) { |
|
55 | 55 | return $url; |
56 | 56 | } |
57 | 57 | |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | $current_domain = $_SERVER['HTTP_HOST']; |
61 | 61 | |
62 | 62 | // If original and current domain match, skip. |
63 | - if ( $original_domain == $current_domain ) { |
|
63 | + if ($original_domain == $current_domain) { |
|
64 | 64 | return $url; |
65 | 65 | } |
66 | 66 | |
67 | - return $this->replace_domain( $url, $original_domain, $current_domain ); |
|
67 | + return $this->replace_domain($url, $original_domain, $current_domain); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | * @param string $new_domain The new domain. |
78 | 78 | * @return string $url The new URL. |
79 | 79 | */ |
80 | - protected function replace_domain( $url, $old_domain, $new_domain ) { |
|
80 | + protected function replace_domain($url, $old_domain, $new_domain) { |
|
81 | 81 | // Prepare original domain and current domain with the current protocol. |
82 | - $protocols = array( 'http://', 'https://' ); |
|
83 | - $current_protocol = ( $this->is_ssl() ? 'https' : 'http' ) . '://'; |
|
82 | + $protocols = array('http://', 'https://'); |
|
83 | + $current_protocol = ($this->is_ssl() ? 'https' : 'http').'://'; |
|
84 | 84 | |
85 | - foreach ( $protocols as $protocol ) { |
|
86 | - $original_base = $protocol . $old_domain; |
|
87 | - $new_base = $current_protocol . $new_domain; |
|
85 | + foreach ($protocols as $protocol) { |
|
86 | + $original_base = $protocol.$old_domain; |
|
87 | + $new_base = $current_protocol.$new_domain; |
|
88 | 88 | |
89 | 89 | // Replace original domain with current domain. |
90 | - $url = str_replace( $original_base, $new_base, $url ); |
|
90 | + $url = str_replace($original_base, $new_base, $url); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $url; |
@@ -101,17 +101,17 @@ discard block |
||
101 | 101 | * @param string $content The current content with the original domain. |
102 | 102 | * @return string $content The content with the new domain. |
103 | 103 | */ |
104 | - public function setup_content( $content ) { |
|
104 | + public function setup_content($content) { |
|
105 | 105 | // Get original home URL. |
106 | - remove_filter( 'option_home', array( $this, 'setup_domain' ), 1 ); |
|
107 | - $original_home = home_url( '/' ); |
|
108 | - add_filter( 'option_home', array( $this, 'setup_domain' ), 1 ); |
|
106 | + remove_filter('option_home', array($this, 'setup_domain'), 1); |
|
107 | + $original_home = home_url('/'); |
|
108 | + add_filter('option_home', array($this, 'setup_domain'), 1); |
|
109 | 109 | |
110 | 110 | // Get current home URL. |
111 | - $current_home = home_url( '/' ); |
|
111 | + $current_home = home_url('/'); |
|
112 | 112 | |
113 | 113 | // Replace occurences of original URL with current home URL. |
114 | - $content = str_replace( $original_home, $current_home, $content ); |
|
114 | + $content = str_replace($original_home, $current_home, $content); |
|
115 | 115 | |
116 | 116 | return $content; |
117 | 117 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param array $upload_dir The current upload dir settings with the original domain. |
125 | 125 | * @return array $upload_dir The upload dir settings with the new domain. |
126 | 126 | */ |
127 | - public function setup_upload_dir( $upload_dir ) { |
|
127 | + public function setup_upload_dir($upload_dir) { |
|
128 | 128 | // Keys of array element that we'll be updating. |
129 | 129 | $keys_to_update = array( |
130 | 130 | 'url', |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | ); |
133 | 133 | |
134 | 134 | // Fix all targeted array elements. |
135 | - foreach ( $keys_to_update as $key ) { |
|
136 | - $upload_dir[ $key ] = apply_filters( 'wp_hydra_domain', $upload_dir[ $key ] ); |
|
135 | + foreach ($keys_to_update as $key) { |
|
136 | + $upload_dir[$key] = apply_filters('wp_hydra_domain', $upload_dir[$key]); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $upload_dir; |
@@ -5,27 +5,27 @@ |
||
5 | 5 | * @package Wp_Hydra |
6 | 6 | */ |
7 | 7 | |
8 | -$_tests_dir = getenv( 'WP_TESTS_DIR' ); |
|
8 | +$_tests_dir = getenv('WP_TESTS_DIR'); |
|
9 | 9 | |
10 | -if ( ! $_tests_dir ) { |
|
11 | - $_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; |
|
10 | +if (!$_tests_dir) { |
|
11 | + $_tests_dir = rtrim(sys_get_temp_dir(), '/\\').'/wordpress-tests-lib'; |
|
12 | 12 | } |
13 | 13 | |
14 | -if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) { |
|
15 | - echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; |
|
16 | - exit( 1 ); |
|
14 | +if (!file_exists($_tests_dir.'/includes/functions.php')) { |
|
15 | + echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?".PHP_EOL; |
|
16 | + exit(1); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // Give access to tests_add_filter() function. |
20 | -require_once $_tests_dir . '/includes/functions.php'; |
|
20 | +require_once $_tests_dir.'/includes/functions.php'; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Manually load the plugin being tested. |
24 | 24 | */ |
25 | 25 | function _manually_load_plugin() { |
26 | - require dirname( dirname( __FILE__ ) ) . '/wp-hydra.php'; |
|
26 | + require dirname(dirname(__FILE__)).'/wp-hydra.php'; |
|
27 | 27 | } |
28 | -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
|
28 | +tests_add_filter('muplugins_loaded', '_manually_load_plugin'); |
|
29 | 29 | |
30 | 30 | // Start up the WP testing environment. |
31 | -require $_tests_dir . '/includes/bootstrap.php'; |
|
31 | +require $_tests_dir.'/includes/bootstrap.php'; |
@@ -13,23 +13,23 @@ discard block |
||
13 | 13 | * Test setup |
14 | 14 | */ |
15 | 15 | public function setUp() { |
16 | - $this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->disableOriginalConstructor()->setMethods( array( 'setup_domain' ) )->getMock(); |
|
16 | + $this->wp_hydra = $this->getMockBuilder('WP_Hydra')->disableOriginalConstructor()->setMethods(array('setup_domain'))->getMock(); |
|
17 | 17 | |
18 | 18 | $this->domain = 'https://foobar.com'; |
19 | 19 | |
20 | - $this->wp_hydra->expects( $this->any() ) |
|
21 | - ->method( 'setup_domain' ) |
|
22 | - ->will( $this->returnValue( $this->domain ) ); |
|
20 | + $this->wp_hydra->expects($this->any()) |
|
21 | + ->method('setup_domain') |
|
22 | + ->will($this->returnValue($this->domain)); |
|
23 | 23 | |
24 | - remove_all_filters( 'option_home', 1 ); |
|
24 | + remove_all_filters('option_home', 1); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Test teardown |
29 | 29 | */ |
30 | 30 | public function tearDown() { |
31 | - unset( $this->wp_hydra ); |
|
32 | - unset( $this->domain ); |
|
31 | + unset($this->wp_hydra); |
|
32 | + unset($this->domain); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function testOccurencesInTheBeginning() { |
41 | 41 | $content = 'https://example.org/ foo bar '; |
42 | - $expected = $this->domain . '/ foo bar '; |
|
43 | - $actual = $this->wp_hydra->setup_content( $content ); |
|
42 | + $expected = $this->domain.'/ foo bar '; |
|
43 | + $actual = $this->wp_hydra->setup_content($content); |
|
44 | 44 | |
45 | - $this->assertSame( $expected, $actual ); |
|
45 | + $this->assertSame($expected, $actual); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function testOccurencesInTheMiddle() { |
54 | 54 | $content = 'helloWorld https://example.org/ foo bar '; |
55 | - $expected = 'helloWorld ' . $this->domain . '/ foo bar '; |
|
56 | - $actual = $this->wp_hydra->setup_content( $content ); |
|
55 | + $expected = 'helloWorld '.$this->domain.'/ foo bar '; |
|
56 | + $actual = $this->wp_hydra->setup_content($content); |
|
57 | 57 | |
58 | - $this->assertSame( $expected, $actual ); |
|
58 | + $this->assertSame($expected, $actual); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function testOccurencesInTheEnd() { |
67 | 67 | $content = 'helloWorld https://example.org/'; |
68 | - $expected = 'helloWorld ' . $this->domain . '/'; |
|
69 | - $actual = $this->wp_hydra->setup_content( $content ); |
|
68 | + $expected = 'helloWorld '.$this->domain.'/'; |
|
69 | + $actual = $this->wp_hydra->setup_content($content); |
|
70 | 70 | |
71 | - $this->assertSame( $expected, $actual ); |
|
71 | + $this->assertSame($expected, $actual); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function testMultipleOccurences() { |
80 | 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 ); |
|
81 | + $expected = $this->domain.'/ helloWorld '.$this->domain.'/ foo bar '.$this->domain.'/'; |
|
82 | + $actual = $this->wp_hydra->setup_content($content); |
|
83 | 83 | |
84 | - $this->assertSame( $expected, $actual ); |
|
84 | + $this->assertSame($expected, $actual); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function testOccurencesInAnImage() { |
93 | 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 ); |
|
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 | 96 | |
97 | - $this->assertSame( $expected, $actual ); |
|
97 | + $this->assertSame($expected, $actual); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function testOccurencesInALink() { |
106 | 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 ); |
|
107 | + $expected = '<a href="'.$this->domain.'/foo/bar/">Test</a>'; |
|
108 | + $actual = $this->wp_hydra->setup_content($content); |
|
109 | 109 | |
110 | - $this->assertSame( $expected, $actual ); |
|
110 | + $this->assertSame($expected, $actual); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | * Test setup. |
15 | 15 | */ |
16 | 16 | public function setUp() { |
17 | - $this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->getMock(); |
|
17 | + $this->wp_hydra = $this->getMockBuilder('WP_Hydra')->getMock(); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Test teardown. |
22 | 22 | */ |
23 | 23 | public function tearDown() { |
24 | - unset( $this->wp_hydra ); |
|
24 | + unset($this->wp_hydra); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -32,22 +32,22 @@ discard block |
||
32 | 32 | public function testHooksRegistered() { |
33 | 33 | $this->wp_hydra->__construct(); |
34 | 34 | |
35 | - $this->assertSame( 1, has_filter( 'option_blogname', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
36 | - $this->assertSame( 1, has_filter( 'option_siteurl', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
37 | - $this->assertSame( 1, has_filter( 'option_home', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
38 | - $this->assertSame( 1, has_filter( 'stylesheet_uri', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
39 | - $this->assertSame( 1, has_filter( 'stylesheet_directory_uri', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
40 | - $this->assertSame( 1, has_filter( 'template_directory_uri', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
35 | + $this->assertSame(1, has_filter('option_blogname', array($this->wp_hydra, 'setup_domain'))); |
|
36 | + $this->assertSame(1, has_filter('option_siteurl', array($this->wp_hydra, 'setup_domain'))); |
|
37 | + $this->assertSame(1, has_filter('option_home', array($this->wp_hydra, 'setup_domain'))); |
|
38 | + $this->assertSame(1, has_filter('stylesheet_uri', array($this->wp_hydra, 'setup_domain'))); |
|
39 | + $this->assertSame(1, has_filter('stylesheet_directory_uri', array($this->wp_hydra, 'setup_domain'))); |
|
40 | + $this->assertSame(1, has_filter('template_directory_uri', array($this->wp_hydra, 'setup_domain'))); |
|
41 | 41 | |
42 | - $this->assertSame( 10, has_filter( 'the_content', array( $this->wp_hydra, 'setup_content' ) ) ); |
|
42 | + $this->assertSame(10, has_filter('the_content', array($this->wp_hydra, 'setup_content'))); |
|
43 | 43 | |
44 | - $this->assertSame( 10, has_filter( 'widget_text', array( $this->wp_hydra, 'setup_content' ) ) ); |
|
44 | + $this->assertSame(10, has_filter('widget_text', array($this->wp_hydra, 'setup_content'))); |
|
45 | 45 | |
46 | - $this->assertSame( 10, has_filter( 'upload_dir', array( $this->wp_hydra, 'setup_upload_dir' ) ) ); |
|
46 | + $this->assertSame(10, has_filter('upload_dir', array($this->wp_hydra, 'setup_upload_dir'))); |
|
47 | 47 | |
48 | - $this->assertSame( 10, has_filter( 'wp_hydra_domain', array( $this->wp_hydra, 'setup_domain' ) ) ); |
|
48 | + $this->assertSame(10, has_filter('wp_hydra_domain', array($this->wp_hydra, 'setup_domain'))); |
|
49 | 49 | |
50 | - $this->assertSame( 10, has_filter( 'wp_hydra_content', array( $this->wp_hydra, 'setup_content' ) ) ); |
|
50 | + $this->assertSame(10, has_filter('wp_hydra_content', array($this->wp_hydra, 'setup_content'))); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * Test setup |
14 | 14 | */ |
15 | 15 | public function setUp() { |
16 | - $this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->setMethods( null )->getMock(); |
|
16 | + $this->wp_hydra = $this->getMockBuilder('WP_Hydra')->setMethods(null)->getMock(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Test teardown |
21 | 21 | */ |
22 | 22 | public function tearDown() { |
23 | - unset( $this->wp_hydra ); |
|
23 | + unset($this->wp_hydra); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | public function testWithWrongURL() { |
32 | 32 | $url = 'foo/com'; |
33 | 33 | |
34 | - $result = $this->wp_hydra->setup_domain( $url ); |
|
34 | + $result = $this->wp_hydra->setup_domain($url); |
|
35 | 35 | |
36 | - $this->assertSame( $url, $result ); |
|
36 | + $this->assertSame($url, $result); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function testWithNoHost() { |
45 | 45 | $original_host = $_SERVER['HTTP_HOST']; |
46 | - unset( $_SERVER['HTTP_HOST'] ); |
|
46 | + unset($_SERVER['HTTP_HOST']); |
|
47 | 47 | |
48 | 48 | $url = 'http://example.xyz/lorem-ipsum/'; |
49 | 49 | |
50 | - $result = $this->wp_hydra->setup_domain( $url ); |
|
50 | + $result = $this->wp_hydra->setup_domain($url); |
|
51 | 51 | |
52 | - $this->assertSame( $url, $result ); |
|
52 | + $this->assertSame($url, $result); |
|
53 | 53 | |
54 | 54 | $_SERVER['HTTP_HOST'] = $original_host; |
55 | 55 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $_SERVER['HTTP_HOST'] = 'example.com'; |
66 | 66 | $url = 'http://example.com/lorem-ipsum/'; |
67 | 67 | |
68 | - $result = $this->wp_hydra->setup_domain( $url ); |
|
68 | + $result = $this->wp_hydra->setup_domain($url); |
|
69 | 69 | |
70 | - $this->assertSame( $url, $result ); |
|
70 | + $this->assertSame($url, $result); |
|
71 | 71 | |
72 | 72 | $_SERVER['HTTP_HOST'] = $original_host; |
73 | 73 | } |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | $_SERVER['HTTP_HOST'] = 'foobar.com'; |
84 | 84 | $original_domain = 'example.com'; |
85 | 85 | $url = 'http://example.com/lorem-ipsum/'; |
86 | - $exposed_instance = $this->getMockBuilder( 'WP_Hydra_Exposed' )->setMethods( null )->getMock(); |
|
86 | + $exposed_instance = $this->getMockBuilder('WP_Hydra_Exposed')->setMethods(null)->getMock(); |
|
87 | 87 | |
88 | - $expected = $exposed_instance->replace_domain_exposed( $url, $original_domain, $current_domain ); |
|
89 | - $actual = $this->wp_hydra->setup_domain( $url ); |
|
88 | + $expected = $exposed_instance->replace_domain_exposed($url, $original_domain, $current_domain); |
|
89 | + $actual = $this->wp_hydra->setup_domain($url); |
|
90 | 90 | |
91 | - $this->assertSame( $expected, $actual ); |
|
91 | + $this->assertSame($expected, $actual); |
|
92 | 92 | |
93 | 93 | $_SERVER['HTTP_HOST'] = $original_host; |
94 | 94 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param string $current_domain The current domain. |
108 | 108 | * @return string String with domain replaced. |
109 | 109 | */ |
110 | - public function replace_domain_exposed( $url, $original_domain, $current_domain ) { |
|
111 | - return $this->replace_domain( $url, $original_domain, $current_domain ); |
|
110 | + public function replace_domain_exposed($url, $original_domain, $current_domain) { |
|
111 | + return $this->replace_domain($url, $original_domain, $current_domain); |
|
112 | 112 | } |
113 | 113 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * Test setup |
14 | 14 | */ |
15 | 15 | public function setUp() { |
16 | - $this->wp_hydra = $this->getMockBuilder( 'WP_Hydra_Exposed_RD' )->setMethods( array( 'is_ssl' ) )->getMock(); |
|
16 | + $this->wp_hydra = $this->getMockBuilder('WP_Hydra_Exposed_RD')->setMethods(array('is_ssl'))->getMock(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Test teardown |
21 | 21 | */ |
22 | 22 | public function tearDown() { |
23 | - unset( $this->wp_hydra ); |
|
23 | + unset($this->wp_hydra); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | * @covers WP_Hydra::replace_domain |
30 | 30 | */ |
31 | 31 | public function testWithHttpUrlAndHttpsOff() { |
32 | - $this->wp_hydra->expects( $this->any() ) |
|
33 | - ->method( 'is_ssl' ) |
|
34 | - ->will( $this->returnValue( false ) ); |
|
32 | + $this->wp_hydra->expects($this->any()) |
|
33 | + ->method('is_ssl') |
|
34 | + ->will($this->returnValue(false)); |
|
35 | 35 | |
36 | 36 | $url = 'http://example.com/'; |
37 | - $result = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' ); |
|
38 | - $this->assertSame( $url, $result ); |
|
37 | + $result = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'example.com'); |
|
38 | + $this->assertSame($url, $result); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | * @covers WP_Hydra::replace_domain |
45 | 45 | */ |
46 | 46 | public function testWithHttpUrlAndHttpsOn() { |
47 | - $this->wp_hydra->expects( $this->any() ) |
|
48 | - ->method( 'is_ssl' ) |
|
49 | - ->will( $this->returnValue( true ) ); |
|
47 | + $this->wp_hydra->expects($this->any()) |
|
48 | + ->method('is_ssl') |
|
49 | + ->will($this->returnValue(true)); |
|
50 | 50 | |
51 | 51 | $url = 'http://example.com/'; |
52 | 52 | $expected = 'https://example.com/'; |
53 | - $actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' ); |
|
54 | - $this->assertSame( $expected, $actual ); |
|
53 | + $actual = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'example.com'); |
|
54 | + $this->assertSame($expected, $actual); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * @covers WP_Hydra::replace_domain |
61 | 61 | */ |
62 | 62 | public function testWithHttpsUrlAndHttpsOff() { |
63 | - $this->wp_hydra->expects( $this->any() ) |
|
64 | - ->method( 'is_ssl' ) |
|
65 | - ->will( $this->returnValue( false ) ); |
|
63 | + $this->wp_hydra->expects($this->any()) |
|
64 | + ->method('is_ssl') |
|
65 | + ->will($this->returnValue(false)); |
|
66 | 66 | |
67 | 67 | $url = 'https://example.com/'; |
68 | 68 | $expected = 'http://example.com/'; |
69 | - $actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' ); |
|
70 | - $this->assertSame( $expected, $actual ); |
|
69 | + $actual = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'example.com'); |
|
70 | + $this->assertSame($expected, $actual); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | * @covers WP_Hydra::replace_domain |
77 | 77 | */ |
78 | 78 | public function testWithHttpsUrlAndHttpsOn() { |
79 | - $this->wp_hydra->expects( $this->any() ) |
|
80 | - ->method( 'is_ssl' ) |
|
81 | - ->will( $this->returnValue( true ) ); |
|
79 | + $this->wp_hydra->expects($this->any()) |
|
80 | + ->method('is_ssl') |
|
81 | + ->will($this->returnValue(true)); |
|
82 | 82 | |
83 | 83 | $url = 'https://example.com/'; |
84 | - $actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'example.com' ); |
|
85 | - $this->assertSame( $url, $actual ); |
|
84 | + $actual = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'example.com'); |
|
85 | + $this->assertSame($url, $actual); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * @covers WP_Hydra::replace_domain |
92 | 92 | */ |
93 | 93 | public function testWithHttpUrlAndHttpsOffAndDifferentDomain() { |
94 | - $this->wp_hydra->expects( $this->any() ) |
|
95 | - ->method( 'is_ssl' ) |
|
96 | - ->will( $this->returnValue( false ) ); |
|
94 | + $this->wp_hydra->expects($this->any()) |
|
95 | + ->method('is_ssl') |
|
96 | + ->will($this->returnValue(false)); |
|
97 | 97 | |
98 | 98 | $url = 'http://example.com/'; |
99 | 99 | $expected = 'http://foobar.com/'; |
100 | - $result = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' ); |
|
101 | - $this->assertSame( $expected, $result ); |
|
100 | + $result = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'foobar.com'); |
|
101 | + $this->assertSame($expected, $result); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | * @covers WP_Hydra::replace_domain |
108 | 108 | */ |
109 | 109 | public function testWithHttpUrlAndHttpsOnAndDifferentDomain() { |
110 | - $this->wp_hydra->expects( $this->any() ) |
|
111 | - ->method( 'is_ssl' ) |
|
112 | - ->will( $this->returnValue( true ) ); |
|
110 | + $this->wp_hydra->expects($this->any()) |
|
111 | + ->method('is_ssl') |
|
112 | + ->will($this->returnValue(true)); |
|
113 | 113 | |
114 | 114 | $url = 'http://example.com/'; |
115 | 115 | $expected = 'https://foobar.com/'; |
116 | - $actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' ); |
|
117 | - $this->assertSame( $expected, $actual ); |
|
116 | + $actual = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'foobar.com'); |
|
117 | + $this->assertSame($expected, $actual); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | * @covers WP_Hydra::replace_domain |
124 | 124 | */ |
125 | 125 | public function testWithHttpsUrlAndHttpsOffAndDifferentDomain() { |
126 | - $this->wp_hydra->expects( $this->any() ) |
|
127 | - ->method( 'is_ssl' ) |
|
128 | - ->will( $this->returnValue( false ) ); |
|
126 | + $this->wp_hydra->expects($this->any()) |
|
127 | + ->method('is_ssl') |
|
128 | + ->will($this->returnValue(false)); |
|
129 | 129 | |
130 | 130 | $url = 'https://example.com/'; |
131 | 131 | $expected = 'http://foobar.com/'; |
132 | - $actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' ); |
|
133 | - $this->assertSame( $expected, $actual ); |
|
132 | + $actual = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'foobar.com'); |
|
133 | + $this->assertSame($expected, $actual); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | * @covers WP_Hydra::replace_domain |
140 | 140 | */ |
141 | 141 | public function testWithHttpsUrlAndHttpsOnAndDifferentDomain() { |
142 | - $this->wp_hydra->expects( $this->any() ) |
|
143 | - ->method( 'is_ssl' ) |
|
144 | - ->will( $this->returnValue( true ) ); |
|
142 | + $this->wp_hydra->expects($this->any()) |
|
143 | + ->method('is_ssl') |
|
144 | + ->will($this->returnValue(true)); |
|
145 | 145 | |
146 | 146 | $url = 'https://example.com/'; |
147 | 147 | $expected = 'https://foobar.com/'; |
148 | - $actual = $this->wp_hydra->replace_domain_exposed( $url, 'example.com', 'foobar.com' ); |
|
149 | - $this->assertSame( $expected, $actual ); |
|
148 | + $actual = $this->wp_hydra->replace_domain_exposed($url, 'example.com', 'foobar.com'); |
|
149 | + $this->assertSame($expected, $actual); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $current_domain The current domain. |
164 | 164 | * @return string String with domain replaced. |
165 | 165 | */ |
166 | - public function replace_domain_exposed( $url, $original_domain, $current_domain ) { |
|
167 | - return $this->replace_domain( $url, $original_domain, $current_domain ); |
|
166 | + public function replace_domain_exposed($url, $original_domain, $current_domain) { |
|
167 | + return $this->replace_domain($url, $original_domain, $current_domain); |
|
168 | 168 | } |
169 | 169 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | * Test setup |
14 | 14 | */ |
15 | 15 | public function setUp() { |
16 | - $this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->disableOriginalConstructor()->setMethods( null )->getMock(); |
|
16 | + $this->wp_hydra = $this->getMockBuilder('WP_Hydra')->disableOriginalConstructor()->setMethods(null)->getMock(); |
|
17 | 17 | |
18 | - add_filter( 'wp_hydra_domain', array( $this, 'wp_hydra_domain' ) ); |
|
18 | + add_filter('wp_hydra_domain', array($this, 'wp_hydra_domain')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Test teardown |
23 | 23 | */ |
24 | 24 | public function tearDown() { |
25 | - remove_filter( 'wp_hydra_domain', array( $this, 'wp_hydra_domain' ) ); |
|
25 | + remove_filter('wp_hydra_domain', array($this, 'wp_hydra_domain')); |
|
26 | 26 | |
27 | - unset( $this->wp_hydra ); |
|
27 | + unset($this->wp_hydra); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | 'url' => 'example.com', |
38 | 38 | 'baseurl' => 'example.com', |
39 | 39 | ); |
40 | - $expected = array( |
|
40 | + $expected = array( |
|
41 | 41 | 'url' => 'foobar.com', |
42 | 42 | 'baseurl' => 'foobar.com', |
43 | 43 | ); |
44 | - $actual = $this->wp_hydra->setup_upload_dir( $upload_dir ); |
|
45 | - $this->assertSame( $expected, $actual ); |
|
44 | + $actual = $this->wp_hydra->setup_upload_dir($upload_dir); |
|
45 | + $this->assertSame($expected, $actual); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | 'foobar' => 'example.com', |
58 | 58 | ); |
59 | 59 | $expected = $upload_dir; |
60 | - $actual = $this->wp_hydra->setup_upload_dir( $upload_dir ); |
|
61 | - $this->assertSame( $expected, $actual ); |
|
60 | + $actual = $this->wp_hydra->setup_upload_dir($upload_dir); |
|
61 | + $this->assertSame($expected, $actual); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $domain The domain. |
68 | 68 | * @return string A different domain domain. |
69 | 69 | */ |
70 | - public function wp_hydra_domain( $domain ) { |
|
70 | + public function wp_hydra_domain($domain) { |
|
71 | 71 | return 'foobar.com'; |
72 | 72 | } |
73 | 73 |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * Test setup |
14 | 14 | */ |
15 | 15 | public function setUp() { |
16 | - $this->wp_hydra = $this->getMockBuilder( 'WP_Hydra' )->setMethods( null )->getMock(); |
|
16 | + $this->wp_hydra = $this->getMockBuilder('WP_Hydra')->setMethods(null)->getMock(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Test teardown |
21 | 21 | */ |
22 | 22 | public function tearDown() { |
23 | - unset( $this->wp_hydra ); |
|
23 | + unset($this->wp_hydra); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function testWithSslDisabled() { |
32 | 32 | $_SERVER['HTTPS'] = 0; |
33 | - $this->assertFalse( $this->wp_hydra->is_ssl() ); |
|
33 | + $this->assertFalse($this->wp_hydra->is_ssl()); |
|
34 | 34 | |
35 | 35 | $_SERVER['HTTPS'] = false; |
36 | - $this->assertFalse( $this->wp_hydra->is_ssl() ); |
|
36 | + $this->assertFalse($this->wp_hydra->is_ssl()); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function testWithSslEnabled() { |
45 | 45 | $_SERVER['HTTPS'] = 1; |
46 | - $this->assertTrue( $this->wp_hydra->is_ssl() ); |
|
46 | + $this->assertTrue($this->wp_hydra->is_ssl()); |
|
47 | 47 | |
48 | 48 | $_SERVER['HTTPS'] = 'on'; |
49 | - $this->assertTrue( $this->wp_hydra->is_ssl() ); |
|
49 | + $this->assertTrue($this->wp_hydra->is_ssl()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |