Changeset 19 in tests for wp-testcase/test_user.php
- Timestamp:
- 09/22/2007 01:59:33 AM (18 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_user.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_user.php
r18 r19 91 91 } 92 92 93 // test usermeta functions in array mode 94 function test_usermeta_array() { 95 96 // some values to set 97 $vals = array( 98 rand_str() => 'val-'.rand_str(), 99 rand_str() => 'val-'.rand_str(), 100 rand_str() => 'val-'.rand_str(), 101 ); 102 103 $user_id = $this->_make_user('author'); 104 105 // there is already some stuff in the array 106 $this->assertTrue(is_array(get_usermeta($user_id))); 107 108 foreach ($vals as $k=>$v) 109 update_usermeta( $user_id, $k, $v ); 110 111 // get the complete usermeta array 112 $out = get_usermeta($user_id); 113 114 // for reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere. 115 // so we'll just check to make sure our values are included somewhere. 116 foreach ($vals as $v) 117 $this->assertTrue(in_array($v, $out)); 118 119 // delete one key and check again 120 $key_to_delete = array_pop(array_keys($vals)); 121 delete_usermeta($user_id, $key_to_delete); 122 $out = get_usermeta($user_id); 123 // make sure that key is excluded from the results 124 foreach ($vals as $k=>$v) { 125 if ($k == $key_to_delete) 126 $this->assertFalse(in_array($v, $out)); 127 else 128 $this->assertTrue(in_array($v, $out)); 129 } 130 } 93 131 } 94 132
Note: See TracChangeset
for help on using the changeset viewer.