Query: Introduce a unit test which will fail when new public query vars are introduced without also updating the test. This adds an extra layer of explicitness to introducing public query vars in order to avoid introducing unintentional clashes with URL query vars that are already in use.
Merges [36045] to the 4.4 branch. Fixes #35115 git-svn-id: https://develop.svn.wordpress.org/branches/4.4@36046 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
36366a5f76
commit
5f07f529a7
72
tests/phpunit/tests/query/vars.php
Normal file
72
tests/phpunit/tests/query/vars.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests to make sure query vars are as expected.
|
||||
*
|
||||
* @group query
|
||||
*/
|
||||
class Tests_Query_Vars extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 35115
|
||||
*/
|
||||
public function testPublicQueryVarsAreAsExpected() {
|
||||
global $wp;
|
||||
$this->assertEquals( array(
|
||||
|
||||
// Static public query vars:
|
||||
'm',
|
||||
'p',
|
||||
'posts',
|
||||
'w',
|
||||
'cat',
|
||||
'withcomments',
|
||||
'withoutcomments',
|
||||
's',
|
||||
'search',
|
||||
'exact',
|
||||
'sentence',
|
||||
'calendar',
|
||||
'page',
|
||||
'paged',
|
||||
'more',
|
||||
'tb',
|
||||
'pb',
|
||||
'author',
|
||||
'order',
|
||||
'orderby',
|
||||
'year',
|
||||
'monthnum',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
'name',
|
||||
'category_name',
|
||||
'tag',
|
||||
'feed',
|
||||
'author_name',
|
||||
'static',
|
||||
'pagename',
|
||||
'page_id',
|
||||
'error',
|
||||
'attachment',
|
||||
'attachment_id',
|
||||
'subpost',
|
||||
'subpost_id',
|
||||
'preview',
|
||||
'robots',
|
||||
'taxonomy',
|
||||
'term',
|
||||
'cpage',
|
||||
'post_type',
|
||||
'embed',
|
||||
|
||||
// Dynamically added public query vars:
|
||||
'post_format',
|
||||
'rest_route',
|
||||
|
||||
), $wp->public_query_vars, 'Care should be taken when introducing new public query vars. See https://core.trac.wordpress.org/ticket/35115' );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user