Changeset 11818 for trunk/tests/phpunit/testcases/members/functions.php
- Timestamp:
- 01/25/2018 07:44:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/members/functions.php
r11747 r11818 102 102 /** 103 103 * @group bp_core_get_user_displayname 104 * @group cache105 */106 public function test_bp_core_get_user_displayname_xprofile_populate_cache() {107 $xprofile_is_active = bp_is_active( 'xprofile' );108 buddypress()->active_components['xprofile'] = '1';109 110 $u = self::factory()->user->create( array(111 'display_name' => 'Foo',112 ) );113 bp_core_get_user_displayname( $u );114 115 $this->assertSame( 'Foo', wp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) );116 117 if ( ! $xprofile_is_active ) {118 unset( buddypress()->active_components['xprofile'] );119 }120 }121 122 /**123 * @group bp_core_get_user_displayname124 * @group cache125 */126 public function test_bp_core_get_user_displayname_xprofile_bust_cache_after_xprofile_update() {127 $xprofile_is_active = bp_is_active( 'xprofile' );128 buddypress()->active_components['xprofile'] = '1';129 130 $u = self::factory()->user->create();131 xprofile_set_field_data( 1, $u, 'Foo Foo' );132 133 $this->assertFalse( wp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) );134 135 if ( ! $xprofile_is_active ) {136 unset( buddypress()->active_components['xprofile'] );137 }138 }139 140 /**141 * @group bp_core_get_user_displayname142 104 */ 143 105 public function test_bp_core_get_user_displayname_xprofile_exists() { … … 156 118 157 119 /** 158 * @group bp_core_get_user_displayname159 */160 public function test_bp_core_get_user_displayname_xprofile_does_not_exist() {161 $bp = buddypress();162 $xprofile_is_active = bp_is_active( 'xprofile' );163 $bp->active_components['xprofile'] = '1';164 165 $u = self::factory()->user->create( array(166 'display_name' => 'Foo Foo',167 ) );168 169 // Delete directly because BP won't let you delete a required170 // field through the API171 global $wpdb;172 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u ) );173 wp_cache_delete( 'bp_user_fullname_' . $u, 'bp' );174 wp_cache_delete( "{$u}:1", 'bp_xprofile_data' );175 176 $this->assertSame( '', xprofile_get_field_data( 1, $u ) );177 $this->assertSame( 'Foo Foo', bp_core_get_user_displayname( $u ) );178 $this->assertSame( 'Foo Foo', xprofile_get_field_data( 1, $u ) );179 180 if ( ! $xprofile_is_active ) {181 unset( $bp->active_components['xprofile'] );182 }183 }184 185 /**186 120 * @group bp_core_get_user_displaynames 187 121 */ … … 196 130 $u1 = self::factory()->user->create(); 197 131 $u2 = self::factory()->user->create(); 198 199 132 xprofile_set_field_data( 1, $u1, 'Foo' ); 200 133 xprofile_set_field_data( 1, $u2, 'Bar' ); … … 216 149 'display_name' => 'Bar', 217 150 ) ); 218 219 151 xprofile_set_field_data( 1, $u1, 'Foo' ); 220 221 // Delete directly because BP won't let you delete a required222 // field through the API223 global $wpdb;224 $bp = buddypress();225 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u2 ) );226 wp_cache_delete( 'bp_user_fullname_' . $u2, 'bp' );227 wp_cache_delete( "{$u2}:1", 'bp_xprofile_data' );228 229 $expected = array(230 $u1 => 'Foo',231 $u2 => 'Bar',232 );233 234 $this->assertSame( $expected, bp_core_get_user_displaynames( array( $u1, $u2, ) ) );235 }236 237 /**238 * @group bp_core_get_user_displaynames239 */240 public function test_bp_core_get_user_displaynames_one_in_cache() {241 $u1 = self::factory()->user->create();242 xprofile_set_field_data( 1, $u1, 'Foo' );243 244 // Fake the cache for $u2245 $u2 = 123;246 wp_cache_set( 'bp_user_fullname_' . $u2, 'Bar', 'bp' );247 152 248 153 $expected = array(
Note: See TracChangeset
for help on using the changeset viewer.