Skip to content

Commit 3deedc0

Browse files
author
Paul Bearne
committed
fixed white space
1 parent 30e825d commit 3deedc0

1 file changed

Lines changed: 57 additions & 28 deletions

File tree

tests/phpunit/tests/admin/includes/misc/gotUrlRewrite.php

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@
1010
*/
1111
class Tests_got_url_rewrite extends WP_UnitTestCase {
1212

13+
/**
14+
* Saved value of the $is_nginx global.
15+
* @var bool
16+
*/
17+
private $prev_nginx;
18+
19+
/**
20+
* Saved value of the $is_caddy global.
21+
* @var bool
22+
*/
23+
private $prev_caddy;
24+
25+
public function set_up() {
26+
parent::set_up();
27+
global $is_nginx, $is_caddy;
28+
$this->prev_nginx = $is_nginx;
29+
$this->prev_caddy = $is_caddy;
30+
}
31+
32+
public function tear_down() {
33+
global $is_nginx, $is_caddy;
34+
$is_nginx = $this->prev_nginx;
35+
$is_caddy = $this->prev_caddy;
36+
parent::tear_down();
37+
}
38+
1339
/**
1440
* Tests that got_url_rewrite() correctly detects URL rewrite support based on server and filters.
1541
*
@@ -19,20 +45,16 @@ class Tests_got_url_rewrite extends WP_UnitTestCase {
1945
*
2046
* @param bool $expected The expected result from got_url_rewrite().
2147
* @param bool $mod_rewrite Whether mod_rewrite is reported as supported.
22-
* @param bool $is_nginx Value for the $is_nginx global.
23-
* @param bool $is_caddy Value for the $is_caddy global.
48+
* @param bool $is_nginx_val Value for the $is_nginx global.
49+
* @param bool $is_caddy_val Value for the $is_caddy global.
2450
* @param bool $iis7_perm Whether IIS7 supports permalinks (simulated).
2551
* @param bool|null $filter_val Optional value for the 'got_url_rewrite' filter.
2652
*/
27-
public function test_got_url_rewrite( $expected, $mod_rewrite, $is_nginx, $is_caddy, $iis7_perm, $filter_val = null ) {
53+
public function test_got_url_rewrite( $expected, $mod_rewrite, $is_nginx_val, $is_caddy_val, $iis7_perm, $filter_val = null ) {
2854
global $is_nginx, $is_caddy;
2955

30-
// Backup globals.
31-
$prev_nginx = $is_nginx;
32-
$prev_caddy = $is_caddy;
33-
34-
$is_nginx = $is_nginx;
35-
$is_caddy = $is_caddy;
56+
$is_nginx = $is_nginx_val;
57+
$is_caddy = $is_caddy_val;
3658

3759
// Mock got_mod_rewrite and iis7_supports_permalinks via filters if possible.
3860
// However, got_url_rewrite calls got_mod_rewrite() which calls apache_mod_loaded.
@@ -54,25 +76,32 @@ public function test_got_url_rewrite( $expected, $mod_rewrite, $is_nginx, $is_ca
5476
if ( null !== $filter_val ) {
5577
remove_filter( 'got_url_rewrite', $filter_val ? '__return_true' : '__return_false' );
5678
}
57-
$is_nginx = $prev_nginx;
58-
$is_caddy = $prev_caddy;
5979
}
6080

61-
/**
62-
* Data provider for test_got_url_rewrite.
63-
*
64-
* @return array[] {
65-
* @type bool $expected The expected result.
66-
* @type bool $mod_rewrite Whether mod_rewrite is supported.
67-
* @type bool $is_nginx Whether server is nginx.
68-
* @type bool $is_caddy Whether server is Caddy.
69-
* @type bool $iis7_perm Whether IIS7 supports permalinks.
70-
* @type bool|null $filter_val Optional filter value.
71-
* }
72-
*/
81+
/**
82+
* Data provider for test_got_url_rewrite.
83+
*
84+
* @return array[] {
85+
* @type bool $expected The expected result.
86+
* @type bool $mod_rewrite Whether mod_rewrite is supported.
87+
* @type bool $is_nginx Whether server is nginx.
88+
* @type bool $is_caddy Whether server is Caddy.
89+
* @type bool $iis7_perm Whether IIS7 supports permalinks.
90+
* @type bool|null $filter_val Optional filter value.
91+
* }
92+
*
93+
* @phpstan-return array<string, array{
94+
* expected: bool,
95+
* mod_rewrite: bool,
96+
* is_nginx: bool,
97+
* is_caddy: bool,
98+
* iis7_perm: bool,
99+
* filter_val?: bool|null,
100+
* }>
101+
*/
73102
public function data_got_url_rewrite() {
74103
return array(
75-
'All false' => array(
104+
'All false' => array(
76105
'expected' => false,
77106
'mod_rewrite' => false,
78107
'is_nginx' => false,
@@ -86,29 +115,29 @@ public function data_got_url_rewrite() {
86115
'is_caddy' => false,
87116
'iis7_perm' => false,
88117
),
89-
'Nginx supported' => array(
118+
'Nginx supported' => array(
90119
'expected' => true,
91120
'mod_rewrite' => false,
92121
'is_nginx' => true,
93122
'is_caddy' => false,
94123
'iis7_perm' => false,
95124
),
96-
'Caddy supported' => array(
125+
'Caddy supported' => array(
97126
'expected' => true,
98127
'mod_rewrite' => false,
99128
'is_nginx' => false,
100129
'is_caddy' => true,
101130
'iis7_perm' => false,
102131
),
103-
'Filter overrides to true' => array(
132+
'Filter overrides to true' => array(
104133
'expected' => true,
105134
'mod_rewrite' => false,
106135
'is_nginx' => false,
107136
'is_caddy' => false,
108137
'iis7_perm' => false,
109138
'filter_val' => true,
110139
),
111-
'Filter overrides to false' => array(
140+
'Filter overrides to false' => array(
112141
'expected' => false,
113142
'mod_rewrite' => true,
114143
'is_nginx' => true,

0 commit comments

Comments
 (0)