-
Notifications
You must be signed in to change notification settings - Fork 3.6k
added test for get_num_queries and wp_get_nocache_headers #1930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pbearne
wants to merge
22
commits into
WordPress:trunk
Choose a base branch
from
pbearne:wp_get_nocache_headers
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
04d4330
added test for get_num_queries and wp_get_nocache_headers
pbearne 796b742
fixed phpcs
pbearne 61849ab
phpcs
pbearne 51ab9bd
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne ceb912b
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne b3bb21b
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne a18b3bd
Update tests/phpunit/tests/functions/wp_get_nocache_headers.php
pbearne 1cb9b3e
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne d30ee68
Update tests/phpunit/tests/functions/wp_get_nocache_headers.php
pbearne ee4959d
Merge branch 'WordPress:trunk' into wp_get_nocache_headers
pbearne 767b0da
Merge branch 'trunk' into wp_get_nocache_headers
peterwilsoncc 561b2ba
Rename file.
peterwilsoncc 6534d17
Various changes to get_num_queries test.
peterwilsoncc a9389e3
Add to wpdb group as it ensures wpdb->num_queries increases.
peterwilsoncc 10b76cc
Rename file.
peterwilsoncc 3400bd1
Various test changes.
peterwilsoncc 61509cd
CS: Remove excessive line break.
peterwilsoncc d3f563e
Apply suggestions from code review
peterwilsoncc 17f3d1f
Descriptions I somehow missed out committing earliuer.
peterwilsoncc 0bc93d3
Merge branch 'trunk' into wp_get_nocache_headers
pbearne 7ed0a59
Update `wp_get_nocache_headers` test to reflect added `no-store, priv…
547c34a
Merge branch 'trunk' into wp_get_nocache_headers
pbearne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @group functions.php | ||
| * @covers ::get_num_queries | ||
| */ | ||
| class Tests_Functions_getNumQueries extends WP_UnitTestCase { | ||
| /** | ||
| * @ticket 54490 | ||
| */ | ||
| public function test_wp_get_num_queries() { | ||
| global $wpdb; | ||
|
|
||
| $current_count = get_num_queries(); | ||
| $this->assertIsInt( $current_count, 'get_num_queries() did not return an integer.' ); | ||
|
|
||
| // do a single db query | ||
| $wpdb->query( "select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='tableName'" ); | ||
|
|
||
| // check the count updated by 1 | ||
| $this->assertSame( $current_count + 1, get_num_queries(), 'The number of queries did not increase by 1.' ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?php | ||
|
peterwilsoncc marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * @group functions.php | ||
| * @covers ::wp_get_nocache_headers | ||
| */ | ||
| class Tests_Functions_wpGetNocacheHeaders extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * @ticket 54490 | ||
| */ | ||
| public function test_wp_get_nocache_headers() { | ||
| $this->assertSameSetsWithIndex( | ||
| array( | ||
| 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', | ||
| 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', | ||
| 'Last-Modified' => false, | ||
| ), | ||
| wp_get_nocache_headers() | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 54490 | ||
| */ | ||
| public function test_filter_nocache_headers() { | ||
| add_filter( | ||
| 'nocache_headers', | ||
| static function() { | ||
| return array( 'filter_name' => 'nocache_headers' ); | ||
| } | ||
| ); | ||
|
|
||
| $this->assertSameSetsWithIndex( | ||
| array( | ||
| 'filter_name' => 'nocache_headers', | ||
| 'Last-Modified' => false, | ||
| ), | ||
| wp_get_nocache_headers() | ||
| ); | ||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.