Skip to content

Commit 37e5e52

Browse files
committed
Tests: add test for WP::parse_request()
This function was effectively completely untested up to now. As this is a huge function, adding a fully featured set of tests for this, is outside of the scope of this ticket. So, for now, I'm just adding one test which specifically tests for the PHP 8.1 issue we want to address.
1 parent eb6b517 commit 37e5e52

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* @group wp
5+
* @covers WP::parse_request
6+
*/
7+
class Tests_WP_ParseRequest extends WP_UnitTestCase {
8+
/**
9+
* @var WP
10+
*/
11+
protected $wp;
12+
13+
public function set_up() {
14+
parent::set_up();
15+
$this->wp = new WP();
16+
}
17+
18+
/**
19+
* Test that no PHP 8.1 "passing null to non-nullable" deprecation is thrown when the
20+
* home URL has no path/trailing slash (default setup).
21+
*
22+
* Note: this doesn't test the actual functioning of the parse_request() method.
23+
* It just and only tests for/against the deprecation notice.
24+
*
25+
* @ticket 53635
26+
*/
27+
public function test_no_deprecation_notice_when_homeurl_has_no_path() {
28+
// Make sure rewrite rules are not empty.
29+
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
30+
31+
// Make sure the test will function independently of whatever the test user set in wp-test-config.php.
32+
add_filter(
33+
'home_url',
34+
static function ( $url ) {
35+
return 'http://example.org';
36+
}
37+
);
38+
39+
$this->wp->parse_request();
40+
$this->assertSame( '', $this->wp->request );
41+
}
42+
}

0 commit comments

Comments
 (0)