Changeset 58782 for trunk/tests/phpunit/tests/option/networkOption.php
- Timestamp:
- 07/23/2024 12:25:19 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/networkOption.php
r56946 r58782 58 58 59 59 /** 60 * Tests that calling delete_network_option() updates nooptions when option deleted. 61 * 62 * @ticket 61484 63 * 64 * @covers ::delete_network_option 65 */ 66 public function test_check_delete_network_option_updates_notoptions() { 67 add_network_option( 1, 'foo', 'value1' ); 68 69 delete_network_option( 1, 'foo' ); 70 $cache_key = is_multisite() ? '1:notoptions' : 'notoptions'; 71 $cache_group = is_multisite() ? 'site-options' : 'options'; 72 $notoptions = wp_cache_get( $cache_key, $cache_group ); 73 $this->assertIsArray( $notoptions, 'The notoptions cache is expected to be an array.' ); 74 $this->assertTrue( $notoptions['foo'], 'The deleted options is expected to be in notoptions.' ); 75 76 $before = get_num_queries(); 77 get_network_option( 1, 'foo' ); 78 $queries = get_num_queries() - $before; 79 80 $this->assertSame( 0, $queries, 'get_network_option should not make any database queries.' ); 81 } 82 83 /** 60 84 * @ticket 22846 61 85 * @group ms-excluded … … 229 253 $this->assertSame( $num_queries_pre_update, get_num_queries() ); 230 254 } 255 256 /** 257 * Tests that calling update_network_option() clears the notoptions cache. 258 * 259 * @ticket 61484 260 * 261 * @covers ::update_network_option 262 */ 263 public function test_update_network_option_clears_the_notoptions_cache() { 264 $option_name = 'ticket_61484_option_to_be_created'; 265 $cache_key = is_multisite() ? '1:notoptions' : 'notoptions'; 266 $cache_group = is_multisite() ? 'site-options' : 'options'; 267 $notoptions = wp_cache_get( $cache_key, $cache_group ); 268 if ( ! is_array( $notoptions ) ) { 269 $notoptions = array(); 270 } 271 $notoptions[ $option_name ] = true; 272 wp_cache_set( $cache_key, $notoptions, $cache_group ); 273 $this->assertArrayHasKey( $option_name, wp_cache_get( $cache_key, $cache_group ), 'The "foobar" option should be in the notoptions cache.' ); 274 275 update_network_option( 1, $option_name, 'baz' ); 276 277 $updated_notoptions = wp_cache_get( $cache_key, $cache_group ); 278 $this->assertArrayNotHasKey( $option_name, $updated_notoptions, 'The "foobar" option should not be in the notoptions cache after updating it.' ); 279 } 280 281 /** 282 * Tests that calling add_network_option() clears the notoptions cache. 283 * 284 * @ticket 61484 285 * 286 * @covers ::add_network_option 287 */ 288 public function test_add_network_option_clears_the_notoptions_cache() { 289 $option_name = 'ticket_61484_option_to_be_created'; 290 $cache_key = is_multisite() ? '1:notoptions' : 'notoptions'; 291 $cache_group = is_multisite() ? 'site-options' : 'options'; 292 $notoptions = wp_cache_get( $cache_key, $cache_group ); 293 if ( ! is_array( $notoptions ) ) { 294 $notoptions = array(); 295 } 296 $notoptions[ $option_name ] = true; 297 wp_cache_set( $cache_key, $notoptions, $cache_group ); 298 $this->assertArrayHasKey( $option_name, wp_cache_get( $cache_key, $cache_group ), 'The "foobar" option should be in the notoptions cache.' ); 299 300 add_network_option( 1, $option_name, 'baz' ); 301 302 $updated_notoptions = wp_cache_get( $cache_key, $cache_group ); 303 $this->assertArrayNotHasKey( $option_name, $updated_notoptions, 'The "foobar" option should not be in the notoptions cache after updating it.' ); 304 } 231 305 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)