Changeset 56595 for trunk/tests/phpunit/tests/option/option.php
- Timestamp:
- 09/15/2023 04:13:52 PM (2 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/option.php
r54147 r56595 102 102 103 103 /** 104 * @ticket 58277 105 * 106 * @covers ::get_option 107 */ 108 public function test_get_option_notoptions_cache() { 109 $notoptions = array( 110 'invalid' => true, 111 ); 112 wp_cache_set( 'notoptions', $notoptions, 'options' ); 113 114 $before = get_num_queries(); 115 $value = get_option( 'invalid' ); 116 $after = get_num_queries(); 117 118 $this->assertSame( 0, $after - $before ); 119 } 120 121 /** 122 * @ticket 58277 123 * 124 * @covers ::get_option 125 */ 126 public function test_get_option_notoptions_set_cache() { 127 get_option( 'invalid' ); 128 129 $before = get_num_queries(); 130 $value = get_option( 'invalid' ); 131 $after = get_num_queries(); 132 133 $notoptions = wp_cache_get( 'notoptions', 'options' ); 134 135 $this->assertSame( 0, $after - $before, 'The notoptions cache was not hit on the second call to `get_option()`.' ); 136 $this->assertIsArray( $notoptions, 'The notoptions cache should be set.' ); 137 $this->assertArrayHasKey( 'invalid', $notoptions, 'The "invalid" option should be in the notoptions cache.' ); 138 } 139 140 /** 141 * @ticket 58277 142 * 143 * @covers ::get_option 144 */ 145 public function test_get_option_notoptions_do_not_load_cache() { 146 add_option( 'foo', 'bar', '', 'no' ); 147 wp_cache_delete( 'notoptions', 'options' ); 148 149 $before = get_num_queries(); 150 $value = get_option( 'foo' ); 151 $after = get_num_queries(); 152 153 $notoptions = wp_cache_get( 'notoptions', 'options' ); 154 155 $this->assertSame( 0, $after - $before, 'The options cache was not hit on the second call to `get_option()`.' ); 156 $this->assertFalse( $notoptions, 'The notoptions cache should not be set.' ); 157 } 158 159 /** 104 160 * @covers ::get_option 105 161 * @covers ::add_option
Note: See TracChangeset
for help on using the changeset viewer.