Changeset 10 in tests
- Timestamp:
- 09/20/2007 01:23:35 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_user_capabilities.php
r4 r10 42 42 43 43 // test the default roles 44 44 45 function test_user_administrator() { 45 46 $id = $this->_make_user('administrator'); … … 130 131 } 131 132 133 // a role that doesn't exist 134 function test_bogus_role() { 135 $id = $this->_make_user(rand_str()); 136 $user = new WP_User($id); 132 137 138 // user has no role and no capabilities 139 $this->assertEquals(array(), $user->roles); 140 $this->assertFalse($user->has_cap('level_0')); 141 } 142 143 // a user with multiple roles 144 function test_user_subscriber_contributor() { 145 $id = $this->_make_user('subscriber'); 146 $user = new WP_User($id); 147 $user->add_role('contributor'); 148 149 // nuke and re-fetch the object to make sure it was stored 150 $user = NULL; 151 $user = new WP_User($id); 152 153 // user should have two roles now 154 $this->assertEquals(array('subscriber', 'contributor'), $user->roles); 155 156 // with contributor capabilities 157 $this->assertTrue($user->has_cap('edit_posts')); 158 $this->assertTrue($user->has_cap('read')); 159 $this->assertTrue($user->has_cap('level_1')); 160 $this->assertTrue($user->has_cap('level_0')); 161 162 // but not these 163 $this->assertFalse($user->has_cap('upload_files')); 164 $this->assertFalse($user->has_cap('edit_published_posts')); 165 $this->assertFalse($user->has_cap('level_2')); 166 } 133 167 } 134 168
Note: See TracChangeset
for help on using the changeset viewer.