Skip to content
Open
Show file tree
Hide file tree
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 Nov 23, 2021
796b742
fixed phpcs
pbearne Nov 23, 2021
61849ab
phpcs
pbearne Nov 23, 2021
51ab9bd
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne Nov 23, 2021
ceb912b
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne Nov 23, 2021
b3bb21b
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne Nov 23, 2021
a18b3bd
Update tests/phpunit/tests/functions/wp_get_nocache_headers.php
pbearne Nov 23, 2021
1cb9b3e
Update tests/phpunit/tests/functions/get_num_queries.php
pbearne Nov 23, 2021
d30ee68
Update tests/phpunit/tests/functions/wp_get_nocache_headers.php
pbearne Nov 23, 2021
ee4959d
Merge branch 'WordPress:trunk' into wp_get_nocache_headers
pbearne Nov 26, 2021
767b0da
Merge branch 'trunk' into wp_get_nocache_headers
peterwilsoncc Nov 5, 2023
561b2ba
Rename file.
peterwilsoncc Nov 5, 2023
6534d17
Various changes to get_num_queries test.
peterwilsoncc Nov 5, 2023
a9389e3
Add to wpdb group as it ensures wpdb->num_queries increases.
peterwilsoncc Nov 5, 2023
10b76cc
Rename file.
peterwilsoncc Nov 5, 2023
3400bd1
Various test changes.
peterwilsoncc Nov 5, 2023
61509cd
CS: Remove excessive line break.
peterwilsoncc Nov 5, 2023
d3f563e
Apply suggestions from code review
peterwilsoncc Nov 5, 2023
17f3d1f
Descriptions I somehow missed out committing earliuer.
peterwilsoncc Nov 6, 2023
0bc93d3
Merge branch 'trunk' into wp_get_nocache_headers
pbearne Jun 26, 2026
7ed0a59
Update `wp_get_nocache_headers` test to reflect added `no-store, priv…
Jun 26, 2026
547c34a
Merge branch 'trunk' into wp_get_nocache_headers
pbearne Jul 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/phpunit/tests/functions/get_num_queries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
Comment thread
peterwilsoncc marked this conversation as resolved.

/**
* @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.' );
}
}
43 changes: 43 additions & 0 deletions tests/phpunit/tests/functions/wp_get_nocache_headers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
Comment thread
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()
);
}

}