Changeset 55745 for trunk/tests/phpunit/tests/post/getPageByPath.php
- Timestamp:
- 05/11/2023 10:05:51 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/post/getPageByPath.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPageByPath.php
r55169 r55745 261 261 */ 262 262 public function test_should_hit_cache() { 263 global $wpdb;264 265 263 $page = self::factory()->post->create( 266 264 array( … … 274 272 $this->assertSame( $page, $found->ID ); 275 273 276 $num_queries = $wpdb->num_queries;277 278 $found = get_page_by_path( 'foo' ); 279 $this->assertSame( $page, $found->ID ); 280 $this->assertSame( $num_queries, $wpdb->num_queries);274 $num_queries = get_num_queries(); 275 276 $found = get_page_by_path( 'foo' ); 277 $this->assertSame( $page, $found->ID ); 278 $this->assertSame( $num_queries, get_num_queries() ); 281 279 } 282 280 … … 285 283 */ 286 284 public function test_bad_path_should_be_cached() { 287 global $wpdb;288 289 285 // Prime cache. 290 286 $found = get_page_by_path( 'foo' ); 291 287 $this->assertNull( $found ); 292 288 293 $num_queries = $wpdb->num_queries;294 295 $found = get_page_by_path( 'foo' ); 296 $this->assertNull( $found ); 297 $this->assertSame( $num_queries, $wpdb->num_queries);289 $num_queries = get_num_queries(); 290 291 $found = get_page_by_path( 'foo' ); 292 $this->assertNull( $found ); 293 $this->assertSame( $num_queries, get_num_queries() ); 298 294 } 299 295 … … 302 298 */ 303 299 public function test_bad_path_served_from_cache_should_not_fall_back_on_current_post() { 304 global $ wpdb, $post;300 global $post; 305 301 306 302 // Fake the global. … … 311 307 $this->assertNull( $found ); 312 308 313 $num_queries = $wpdb->num_queries;314 315 $found = get_page_by_path( 'foo' ); 316 $this->assertNull( $found ); 317 $this->assertSame( $num_queries, $wpdb->num_queries);309 $num_queries = get_num_queries(); 310 311 $found = get_page_by_path( 'foo' ); 312 $this->assertNull( $found ); 313 $this->assertSame( $num_queries, get_num_queries() ); 318 314 319 315 unset( $post ); … … 324 320 */ 325 321 public function test_cache_should_not_match_post_in_different_post_type_with_same_path() { 326 global $wpdb;327 328 322 register_post_type( 'wptests_pt' ); 329 323 … … 346 340 $this->assertSame( $p1, $found->ID ); 347 341 348 $num_queries = $wpdb->num_queries;342 $num_queries = get_num_queries(); 349 343 350 344 $found = get_page_by_path( 'foo', OBJECT, 'wptests_pt' ); 351 345 $this->assertSame( $p2, $found->ID ); 352 346 $num_queries++; 353 $this->assertSame( $num_queries, $wpdb->num_queries);347 $this->assertSame( $num_queries, get_num_queries() ); 354 348 } 355 349 … … 358 352 */ 359 353 public function test_cache_should_be_invalidated_when_post_name_is_edited() { 360 global $wpdb;361 362 354 $page = self::factory()->post->create( 363 355 array( … … 378 370 ); 379 371 380 $num_queries = $wpdb->num_queries;372 $num_queries = get_num_queries(); 381 373 382 374 $found = get_page_by_path( 'bar' ); 383 375 $this->assertSame( $page, $found->ID ); 384 376 $num_queries++; 385 $this->assertSame( $num_queries, $wpdb->num_queries);377 $this->assertSame( $num_queries, get_num_queries() ); 386 378 } 387 379
Note: See TracChangeset
for help on using the changeset viewer.