Skip to content

Commit 38f5cdf

Browse files
committed
Tests: Cover wp_removable_query_args().
Verify representative default removable query arguments and additions and removals through the `removable_query_args` filter. Developed in: #14416 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64511 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3c6484f commit 38f5cdf

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* Tests for the wp_removable_query_args() function.
5+
*
6+
* @group functions
7+
*
8+
* @covers ::wp_removable_query_args
9+
*/
10+
class Tests_Functions_WpRemovableQueryArgs extends WP_UnitTestCase {
11+
12+
/**
13+
* Tests that the function returns a list of removable query arg names.
14+
*
15+
* @ticket 65819
16+
*/
17+
public function test_returns_default_removable_query_args() {
18+
$args = wp_removable_query_args();
19+
20+
$this->assertIsArray( $args );
21+
$this->assertNotEmpty( $args );
22+
$this->assertContains( 'settings-updated', $args );
23+
$this->assertContains( 'message', $args );
24+
$this->assertContains( 'activated', $args );
25+
$this->assertContains( 'doing_wp_cron', $args );
26+
$this->assertContains( 'wp-post-new-reload', $args );
27+
}
28+
29+
/**
30+
* Tests that the removable_query_args filter can modify the list.
31+
*
32+
* @ticket 65819
33+
*/
34+
public function test_removable_query_args_filter() {
35+
add_filter(
36+
'removable_query_args',
37+
static function ( $args ) {
38+
$args[] = 'custom_notice';
39+
return array_values( array_diff( $args, array( 'message' ) ) );
40+
}
41+
);
42+
43+
$args = wp_removable_query_args();
44+
45+
$this->assertContains( 'custom_notice', $args );
46+
$this->assertNotContains( 'message', $args );
47+
}
48+
}

0 commit comments

Comments
 (0)