Changeset 21 in tests
- Timestamp:
- 09/22/2007 02:44:11 AM (18 years ago)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_user.php
r20 r21 8 8 9 9 function setUp() { 10 parent::setUp(); 10 11 // keep track of users we create 11 12 $user_ids = array(); … … 13 14 14 15 function tearDown() { 16 parent::tearDown(); 15 17 // delete any users that were created during tests 16 18 foreach ($this->user_ids as $id) … … 120 122 // get the complete usermeta array 121 123 $out = get_usermeta($user_id); 122 124 123 125 // for reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere. 124 126 // so we'll just check to make sure our values are included somewhere. … … 138 140 } 139 141 } 142 143 // simple test for user dropdown 144 function test_wp_dropdown_users() { 145 // add some users 146 foreach (array('administrator', 'editor', 'author', 'contributor', 'subscriber') as $role) { 147 $id = $this->_make_user($role, "test-{$role}"); 148 $user[] = $id; 149 } 150 151 $expected = <<<EOF 152 <select name='user' id='user' class=''> 153 <option value='1'>{$this->author->display_name}</option> 154 <option value='{$user[0]}'>test-administrator</option> 155 <option value='{$user[1]}'>test-editor</option> 156 <option value='{$user[2]}'>test-author</option> 157 <option value='{$user[3]}'>test-contributor</option> 158 <option value='{$user[4]}'>test-subscriber</option> 159 </select> 160 EOF; 161 162 $out = wp_dropdown_users('echo=0&orderby=ID'); 163 164 $this->assertEquals(strip_ws($expected), strip_ws($out)); 165 } 140 166 } 141 167 -
wp-testlib/utils.php
r11 r21 5 5 function rand_str($len=32) { 6 6 return substr(md5(uniqid(rand())), 0, $len); 7 } 8 9 // strip leading and trailing whitespace from each line in the string 10 function strip_ws($txt) { 11 $lines = explode("\n", $txt); 12 $result = array(); 13 foreach ($lines as $line) 14 if (trim($line)) 15 $result[] = trim($line); 16 17 return trim(join("\n", $result)); 7 18 } 8 19
Note: See TracChangeset
for help on using the changeset viewer.