| | 165 | /** |
| | 166 | * Test the magic __unset method |
| | 167 | * |
| | 168 | * @ticket 20043 |
| | 169 | */ |
| | 170 | public function test_user_unset() { |
| | 171 | // New user |
| | 172 | $user_id = $this->factory->user->create( array( 'role' => 'author' ) ); |
| | 173 | $user = new WP_User( $user_id ); |
| | 174 | |
| | 175 | // Test custom fields |
| | 176 | $user->customField = 123; |
| | 177 | $this->assertEquals( $user->customField, 123 ); |
| | 178 | unset( $user->customField ); |
| | 179 | $this->assertFalse( isset( $user->customField ) ); |
| | 180 | return $user; |
| | 181 | } |
| | 182 | |
| | 183 | /** |
| | 184 | * @depends test_user_unset |
| | 185 | * @expectedDeprecated WP_User->id |
| | 186 | * @ticket 20043 |
| | 187 | */ |
| | 188 | function test_user_unset_lowercase_id( $user ) { |
| | 189 | // Test 'id' (lowercase) |
| | 190 | unset( $user->id ); |
| | 191 | return $user; |
| | 192 | } |
| | 193 | |
| | 194 | /** |
| | 195 | * @depends test_user_unset_lowercase_id |
| | 196 | * @ticket 20043 |
| | 197 | */ |
| | 198 | function test_user_unset_uppercase_id( $user ) { |
| | 199 | // Test 'ID' |
| | 200 | $this->assertNotEmpty( $user->ID ); |
| | 201 | unset( $user->ID ); |
| | 202 | $this->assertEmpty( $user->ID ); |
| | 203 | } |
| | 204 | |