Changeset 11352 for trunk/tests/phpunit/testcases/xprofile/cache.php
- Timestamp:
- 12/29/2016 02:16:02 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/testcases/xprofile/cache.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/xprofile/cache.php
r10198 r11352 165 165 $this->assertSame( 'Bar', $field_2->name ); 166 166 } 167 168 /** 169 * @ticket BP7407 170 */ 171 public function test_get_field_id_from_name_should_be_cached() { 172 global $wpdb; 173 174 $g = $this->factory->xprofile_group->create(); 175 $f = $this->factory->xprofile_field->create( array( 176 'field_group_id' => $g, 177 'name' => 'Foo', 178 ) ); 179 180 // Prime cache. 181 BP_XProfile_Field::get_id_from_name( 'Foo' ); 182 183 $num_queries = $wpdb->num_queries; 184 185 $this->assertSame( $f, BP_XProfile_Field::get_id_from_name( 'Foo' ) ); 186 $this->assertSame( $num_queries, $wpdb->num_queries ); 187 } 188 189 /** 190 * @ticket BP7407 191 */ 192 public function test_get_field_id_from_name_cache_should_be_invalidated_on_field_update() { 193 $g = $this->factory->xprofile_group->create(); 194 $f1 = $this->factory->xprofile_field->create( array( 195 'field_group_id' => $g, 196 'name' => 'Foo', 197 ) ); 198 $f2 = $this->factory->xprofile_field->create( array( 199 'field_group_id' => $g, 200 'name' => 'Bar', 201 ) ); 202 203 // Prime cache. 204 xprofile_get_field_id_from_name( 'Foo' ); 205 xprofile_get_field_id_from_name( 'Bar' ); 206 207 // Free up the name 'Bar'. 208 $field2 = xprofile_get_field( $f2 ); 209 $field2->name = 'Quz'; 210 $field2->save(); 211 212 // Take the name 'Bar'. 213 $field1 = xprofile_get_field( $f1 ); 214 $field1->name = 'Bar'; 215 $field1->save(); 216 217 $this->assertSame( $f1, BP_XProfile_Field::get_id_from_name( 'Bar' ) ); 218 } 219 220 /** 221 * @ticket BP7407 222 */ 223 public function test_get_field_id_from_name_cache_should_be_invalidated_on_field_deletion() { 224 $g = $this->factory->xprofile_group->create(); 225 $f = $this->factory->xprofile_field->create( array( 226 'field_group_id' => $g, 227 'name' => 'Foo', 228 ) ); 229 230 // Prime cache. 231 xprofile_get_field_id_from_name( 'Foo' ); 232 233 xprofile_delete_field( $f ); 234 235 $this->assertNull( BP_XProfile_Field::get_id_from_name( 'Bar' ) ); 236 } 167 237 }
Note: See TracChangeset
for help on using the changeset viewer.