Changeset 55747 for trunk/tests/phpunit/tests/multisite/siteMeta.php
- Timestamp:
- 05/11/2023 11:13:10 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/siteMeta.php
r55745 r55747 249 249 $num_queries = get_num_queries(); 250 250 get_site_meta( self::$site_id, 'foo', true ); 251 $this->assertSame( $num_queries, get_num_queries() ); 251 $this->assertSame( 1, get_num_queries() - $num_queries ); 252 } 253 254 /** 255 * @ticket 58185 256 */ 257 public function test_lazy_load_site_meta() { 258 if ( ! is_site_meta_supported() ) { 259 $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' ); 260 } 261 262 $filter = new MockAction(); 263 add_filter( 'update_blog_metadata_cache', array( $filter, 'filter' ), 10, 2 ); 264 265 $q = new WP_Site_Query( 266 array( 267 'ID' => self::$site_id, 268 ) 269 ); 270 271 $this->assertSameSets( array( (string) self::$site_id ), wp_list_pluck( $q->sites, 'blog_id' ), 'Site query should return the first test site' ); 272 273 $q = new WP_Site_Query( 274 array( 275 'ID' => self::$site_id2, 276 ) 277 ); 278 279 $this->assertSameSets( array( (string) self::$site_id2 ), wp_list_pluck( $q->sites, 'blog_id' ), 'Site query should return the second test site' ); 280 281 get_site_meta( self::$site_id2 ); 282 283 $args = $filter->get_args(); 284 $first = reset( $args ); 285 $site_ids = end( $first ); 286 $this->assertSameSets( $site_ids, array( self::$site_id, self::$site_id2 ), 'This should have two site\'s meta' ); 287 } 288 289 /** 290 * @ticket 58185 291 */ 292 public function test_lazy_load_site_meta_fields_id() { 293 if ( ! is_site_meta_supported() ) { 294 $this->markTestSkipped( 'Test only runs with the blogmeta database table installed.' ); 295 } 296 297 $filter = new MockAction(); 298 add_filter( 'update_blog_metadata_cache', array( $filter, 'filter' ), 10, 2 ); 299 300 $q = new WP_Site_Query( 301 array( 302 'ID' => self::$site_id, 303 'fields' => 'ids', 304 ) 305 ); 306 307 $this->assertSameSets( array( self::$site_id ), $q->sites, 'Site query should return the first test site' ); 308 309 $q = new WP_Site_Query( 310 array( 311 'ID' => self::$site_id2, 312 'fields' => 'ids', 313 ) 314 ); 315 316 $this->assertSameSets( array( self::$site_id2 ), $q->sites, 'Site query should return the second test site' ); 317 318 get_site_meta( self::$site_id2 ); 319 320 $args = $filter->get_args(); 321 $first = reset( $args ); 322 $site_ids = end( $first ); 323 $this->assertSameSets( $site_ids, array( self::$site_id, self::$site_id2 ), 'This should have two sites meta' ); 252 324 } 253 325 … … 268 340 $num_queries = get_num_queries(); 269 341 get_site_meta( self::$site_id, 'foo', true ); 270 $this->assertSame( $num_queries + 1, get_num_queries());342 $this->assertSame( 1, get_num_queries() - $num_queries ); 271 343 } 272 344
Note: See TracChangeset
for help on using the changeset viewer.