Changeset 38521
- Timestamp:
- 09/05/2016 10:59:42 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r38516 r38521 49 49 } 50 50 51 protected function _getSingleSiteCaps() {51 final private function _getSingleSitePrimitiveCaps() { 52 52 return array( 53 53 … … 74 74 'install_plugins' => array( 'administrator' ), 75 75 'install_themes' => array( 'administrator' ), 76 'upload_plugins' => array( 'administrator' ),77 'upload_themes' => array( 'administrator' ),78 76 'update_core' => array( 'administrator' ), 79 77 'update_plugins' => array( 'administrator' ), 80 78 'update_themes' => array( 'administrator' ), 81 79 'edit_theme_options' => array( 'administrator' ), 82 'customize' => array( 'administrator' ),83 80 'export' => array( 'administrator' ), 84 81 'import' => array( 'administrator' ), 85 82 'list_users' => array( 'administrator' ), 86 83 'manage_options' => array( 'administrator' ), 87 'delete_site' => array( 'administrator' ),88 'add_users' => array( 'administrator' ),89 84 'promote_users' => array( 'administrator' ), 90 85 'remove_users' => array( 'administrator' ), … … 142 137 } 143 138 144 protected function _getMultiSiteCaps() {139 final private function _getMultiSitePrimitiveCaps() { 145 140 return array( 146 141 … … 166 161 'install_plugins' => array(), 167 162 'install_themes' => array(), 168 'upload_plugins' => array(),169 'upload_themes' => array(),170 163 'update_core' => array(), 171 164 'update_plugins' => array(), … … 173 166 174 167 'edit_theme_options' => array( 'administrator' ), 175 'customize' => array( 'administrator' ),176 168 'export' => array( 'administrator' ), 177 169 'import' => array( 'administrator' ), 178 170 'list_users' => array( 'administrator' ), 179 171 'manage_options' => array( 'administrator' ), 180 'delete_site' => array( 'administrator' ),181 'add_users' => array( 'administrator' ),182 172 'promote_users' => array( 'administrator' ), 183 173 'remove_users' => array( 'administrator' ), … … 235 225 } 236 226 237 protected function getCapsAndRoles() { 227 final private function _getSingleSiteMetaCaps() { 228 return array( 229 'upload_plugins' => array( 'administrator' ), 230 'upload_themes' => array( 'administrator' ), 231 'customize' => array( 'administrator' ), 232 'delete_site' => array( 'administrator' ), 233 'add_users' => array( 'administrator' ), 234 ); 235 } 236 237 final private function _getMultiSiteMetaCaps() { 238 return array( 239 'upload_plugins' => array( 'administrator' ), 240 'upload_themes' => array( 'administrator' ), 241 'customize' => array( 'administrator' ), 242 'delete_site' => array( 'administrator' ), 243 'add_users' => array( 'administrator' ), 244 ); 245 } 246 247 protected function getAllCapsAndRoles() { 248 return $this->getPrimitiveCapsAndRoles() + $this->getMetaCapsAndRoles(); 249 } 250 251 protected function getPrimitiveCapsAndRoles() { 238 252 if ( is_multisite() ) { 239 return $this->_getMultiSite Caps();253 return $this->_getMultiSitePrimitiveCaps(); 240 254 } else { 241 return $this->_getSingleSiteCaps(); 255 return $this->_getSingleSitePrimitiveCaps(); 256 } 257 } 258 259 protected function getMetaCapsAndRoles() { 260 if ( is_multisite() ) { 261 return $this->_getMultiSiteMetaCaps(); 262 } else { 263 return $this->_getSingleSiteMetaCaps(); 242 264 } 243 265 } … … 245 267 // test the tests 246 268 function test_single_and_multisite_cap_tests_match() { 247 $single = $this->_getSingleSiteCaps(); 248 $multi = $this->_getMultiSiteCaps(); 269 $single = $this->_getSingleSitePrimitiveCaps(); 270 $multi = $this->_getMultiSitePrimitiveCaps(); 271 $this->assertEquals( array_keys( $single ), array_keys( $multi ) ); 272 273 $single = $this->_getSingleSiteMetaCaps(); 274 $multi = $this->_getMultiSiteMetaCaps(); 249 275 $this->assertEquals( array_keys( $single ), array_keys( $multi ) ); 250 276 } … … 252 278 // test the tests 253 279 function test_all_caps_of_users_are_being_tested() { 254 $caps = $this->get CapsAndRoles();280 $caps = $this->getPrimitiveCapsAndRoles(); 255 281 256 282 // `manage_links` is a special case … … 283 309 // test the default roles and caps 284 310 function test_all_roles_and_caps() { 285 $caps = $this->get CapsAndRoles();311 $caps = $this->getAllCapsAndRoles(); 286 312 287 313 foreach ( self::$users as $role => $user ) { … … 363 389 return; 364 390 } 365 $caps = $this->get CapsAndRoles();391 $caps = $this->getAllCapsAndRoles(); 366 392 367 393 $user = self::$users['administrator']; … … 393 419 $this->assertEquals( array(), $user->roles, "User should not have any roles" ); 394 420 395 $caps = $this->get CapsAndRoles();421 $caps = $this->getAllCapsAndRoles(); 396 422 397 423 foreach ( $caps as $cap => $roles ) { … … 413 439 $this->assertEquals( array( 'subscriber', 'contributor' ), $user->roles ); 414 440 415 $caps = $this->get CapsAndRoles();441 $caps = $this->getAllCapsAndRoles(); 416 442 417 443 foreach ( $caps as $cap => $roles ) { … … 449 475 $this->assertEquals( array( $role_name ), $user->roles ); 450 476 451 $caps = $this->get CapsAndRoles();477 $caps = $this->getAllCapsAndRoles(); 452 478 453 479 foreach ( $caps as $cap => $roles ) { … … 486 512 $this->assertEquals( array( $role_name ), $user->roles ); 487 513 488 $caps = $this->get CapsAndRoles();514 $caps = $this->getPrimitiveCapsAndRoles(); 489 515 490 516 foreach ( $caps as $cap => $roles ) { … … 1255 1281 $this->assertFalse( is_user_logged_in() ); 1256 1282 1257 $caps = $this->get CapsAndRoles();1283 $caps = $this->getAllCapsAndRoles(); 1258 1284 1259 1285 foreach ( $caps as $cap => $roles ) {
Note: See TracChangeset
for help on using the changeset viewer.