Changeset 55745 for trunk/tests/phpunit/tests/option/updateOption.php
- Timestamp:
- 05/11/2023 10:05:51 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/option/updateOption.php
r53865 r55745 29 29 */ 30 30 public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_missing() { 31 global $wpdb;32 31 $this->flush_cache(); 33 32 update_option( 'test_update_option_default', 'value' ); … … 37 36 wp_load_alloptions(); 38 37 39 $before = $wpdb->num_queries;40 $value = get_option( 'test_update_option_default' ); 41 $after = $wpdb->num_queries;38 $before = get_num_queries(); 39 $value = get_option( 'test_update_option_default' ); 40 $after = get_num_queries(); 42 41 43 42 $this->assertSame( $before, $after ); … … 53 52 */ 54 53 public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_yes() { 55 global $wpdb;56 54 $this->flush_cache(); 57 55 update_option( 'test_update_option_default', 'value', 'yes' ); … … 61 59 wp_load_alloptions(); 62 60 63 $before = $wpdb->num_queries;64 $value = get_option( 'test_update_option_default' ); 65 $after = $wpdb->num_queries;61 $before = get_num_queries(); 62 $value = get_option( 'test_update_option_default' ); 63 $after = get_num_queries(); 66 64 67 65 $this->assertSame( $before, $after ); … … 77 75 */ 78 76 public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_no() { 79 global $wpdb;80 77 $this->flush_cache(); 81 78 update_option( 'test_update_option_default', 'value', 'no' ); … … 85 82 wp_load_alloptions(); 86 83 87 $before = $wpdb->num_queries;88 $value = get_option( 'test_update_option_default' ); 89 $after = $wpdb->num_queries;84 $before = get_num_queries(); 85 $value = get_option( 'test_update_option_default' ); 86 $after = get_num_queries(); 90 87 91 88 // Database has been hit. … … 102 99 */ 103 100 public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_false() { 104 global $wpdb;105 101 $this->flush_cache(); 106 102 update_option( 'test_update_option_default', 'value', false ); … … 110 106 wp_load_alloptions(); 111 107 112 $before = $wpdb->num_queries;113 $value = get_option( 'test_update_option_default' ); 114 $after = $wpdb->num_queries;108 $before = get_num_queries(); 109 $value = get_option( 'test_update_option_default' ); 110 $after = get_num_queries(); 115 111 116 112 // Database has been hit. … … 127 123 */ 128 124 public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() { 129 global $wpdb;130 125 add_option( 'foo', 'bar', '', 'no' ); 131 126 $updated = update_option( 'foo', 'bar2', true ); … … 137 132 wp_load_alloptions(); 138 133 139 $before = $wpdb->num_queries;134 $before = get_num_queries(); 140 135 $value = get_option( 'foo' ); 141 136 142 $this->assertSame( $before, $wpdb->num_queries);137 $this->assertSame( $before, get_num_queries() ); 143 138 $this->assertSame( $value, 'bar2' ); 144 139 } … … 152 147 */ 153 148 public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() { 154 global $wpdb;155 149 add_option( 'foo', 'bar', '', 'yes' ); 156 150 $updated = update_option( 'foo', 'bar', false ); … … 162 156 wp_load_alloptions(); 163 157 164 $before = $wpdb->num_queries;158 $before = get_num_queries(); 165 159 $value = get_option( 'foo' ); 166 160 167 161 // 'foo' should still be autoload=yes, so we should see no additional querios. 168 $this->assertSame( $before, $wpdb->num_queries);162 $this->assertSame( $before, get_num_queries() ); 169 163 $this->assertSame( $value, 'bar' ); 170 164 } … … 178 172 */ 179 173 public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() { 180 global $wpdb;181 174 add_option( 'foo', 'bar', '', 'yes' ); 182 175 … … 190 183 wp_load_alloptions(); 191 184 192 $before = $wpdb->num_queries;185 $before = get_num_queries(); 193 186 $value = get_option( 'foo' ); 194 187 195 188 // 'foo' should still be autoload=yes, so we should see no additional queries. 196 $this->assertSame( $before, $wpdb->num_queries);189 $this->assertSame( $before, get_num_queries() ); 197 190 $this->assertSame( $value, 'bar2' ); 198 191 }
Note: See TracChangeset
for help on using the changeset viewer.