forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseRequest.php
More file actions
59 lines (50 loc) · 1.45 KB
/
parseRequest.php
File metadata and controls
59 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* @group wp
*
* @covers WP::parse_request
*/
class Tests_WP_ParseRequest extends WP_UnitTestCase {
/**
* @var WP
*/
protected $wp;
public function set_up() {
parent::set_up();
$this->wp = new WP();
}
/**
* Tests the return value of the parse_request() method.
*
* @ticket 10886
*/
public function test_parse_request_returns_bool() {
// Check that parse_request() returns true by default.
$this->assertTrue( $this->wp->parse_request() );
add_filter( 'do_parse_request', '__return_false' );
// Check that parse_request() returns false if the request was not parsed.
$this->assertFalse( $this->wp->parse_request() );
}
/**
* Tests that PHP 8.1 "passing null to non-nullable" deprecation notice
* is not thrown when the home URL has no path/trailing slash (default setup).
*
* Note: This does not test the actual functioning of the parse_request() method.
* It just and only tests for/against the deprecation notice.
*
* @ticket 53635
*/
public function test_no_deprecation_notice_when_home_url_has_no_path() {
// Make sure rewrite rules are not empty.
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
// Make sure the test will function independently of whatever the test user set in wp-tests-config.php.
add_filter(
'home_url',
static function ( $url ) {
return 'http://example.org';
}
);
$this->wp->parse_request();
$this->assertSame( '', $this->wp->request );
}
}