本文整理匯總了PHP中WooThemes_Sensei_Utils::update_user_data方法的典型用法代碼示例。如果您正苦於以下問題:PHP WooThemes_Sensei_Utils::update_user_data方法的具體用法?PHP WooThemes_Sensei_Utils::update_user_data怎麽用?PHP WooThemes_Sensei_Utils::update_user_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::update_user_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDeleteUserData
/**
* This tests Woothemes_Sensei_Utils::delete_user_data
*/
public function testDeleteUserData()
{
// does this function add_user_data exist?
$this->assertTrue(method_exists('WooThemes_Sensei_Utils', 'delete_user_data'), 'The utils class function `delete_user_data` does not exist ');
// does it return false for invalid the parameters?
$invalid_data_message = 'This function does not check false data correctly';
$this->assertFalse(WooThemes_Sensei_Utils::delete_user_data('', '', ''), $invalid_data_message . ": '','','' ");
$this->assertFalse(WooThemes_Sensei_Utils::delete_user_data(' ', ' ', ' '), $invalid_data_message . ": ' ', ' ', ' ' ");
$this->assertFalse(WooThemes_Sensei_Utils::delete_user_data(-1, -2, -3), $invalid_data_message . ": -1,-2, -3 ");
$this->assertFalse(WooThemes_Sensei_Utils::delete_user_data('key', 500, 5000), $invalid_data_message . ": 500, 'key', 5000");
// setup the data for the next assertions
$test_user_id = wp_create_user('testDeleteUserData', 'testDeleteUserData', 'testDeleteUserData@test.com');
$test_array = array(1, 2, 3, 4);
$test_lesson_id = $this->factory->post->create(array('post_type' => "lesson"));
$test_data_key = 'test_key';
//does this function return false when there is no lesson status?
$this->assertFalse(WooThemes_Sensei_Utils::get_user_data($test_data_key, $test_lesson_id, $test_user_id), 'This function should return false when the status has not be set for the given post type');
//setup assertion data
WooThemes_Sensei_Utils::update_user_data($test_data_key, $test_lesson_id, $test_array, $test_user_id);
$deleted = WooThemes_Sensei_Utils::delete_user_data($test_data_key, $test_lesson_id, $test_user_id);
$retrieved_value = WooThemes_Sensei_Utils::get_user_data($test_data_key, $test_lesson_id, $test_user_id);
// doest the function successfully delete existing Sensei user data ?
$this->assertTrue($deleted, 'The user data should have been deleted, but was not');
$this->assertEmpty($retrieved_value, 'After deleting the user data should return false');
}