Add tests for update_user_caches()
.
See #24635. git-svn-id: https://develop.svn.wordpress.org/trunk@34918 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ee251924b3
commit
e1d7108e79
53
tests/phpunit/tests/user/updateUserCaches.php
Normal file
53
tests/phpunit/tests/user/updateUserCaches.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group user
|
||||
*/
|
||||
class Tests_User_UpdateUserCaches extends WP_UnitTestCase {
|
||||
public function test_should_store_entire_database_row_in_users_bucket() {
|
||||
global $wpdb;
|
||||
|
||||
$u = $this->factory->user->create();
|
||||
$raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) );
|
||||
|
||||
update_user_caches( $raw_userdata );
|
||||
|
||||
$this->assertEquals( $raw_userdata, wp_cache_get( $u, 'users' ) );
|
||||
}
|
||||
|
||||
public function test_should_store_user_id_in_userlogins_bucket() {
|
||||
$data = new stdClass();
|
||||
$data->ID = 12345;
|
||||
$data->user_login = 'foo';
|
||||
$data->user_email = 'foo@example.com';
|
||||
$data->user_nicename = 'bar';
|
||||
|
||||
update_user_caches( $data );
|
||||
|
||||
$this->assertEquals( 12345, wp_cache_get( 'foo', 'userlogins' ) );
|
||||
}
|
||||
|
||||
public function test_should_store_user_id_in_useremail_bucket() {
|
||||
$data = new stdClass();
|
||||
$data->ID = 12345;
|
||||
$data->user_login = 'foo';
|
||||
$data->user_email = 'foo@example.com';
|
||||
$data->user_nicename = 'bar';
|
||||
|
||||
update_user_caches( $data );
|
||||
|
||||
$this->assertEquals( 12345, wp_cache_get( 'foo@example.com', 'useremail' ) );
|
||||
}
|
||||
|
||||
public function test_should_store_user_id_in_userslugs_bucket() {
|
||||
$data = new stdClass();
|
||||
$data->ID = 12345;
|
||||
$data->user_login = 'foo';
|
||||
$data->user_email = 'foo@example.com';
|
||||
$data->user_nicename = 'bar';
|
||||
|
||||
update_user_caches( $data );
|
||||
|
||||
$this->assertEquals( 12345, wp_cache_get( 'bar', 'userslugs' ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user