Ticket #17850: 17850-tests.diff
File 17850-tests.diff, 1.4 KB (added by , 13 years ago) |
---|
-
wp-testcase/test_user_capabilities.php
29 29 #$GLOBALS['wp_roles'] = new WP_Roles(); 30 30 } 31 31 32 function _meta_yes_you_can( $key, $post_id, $user_id, $cap ) { 33 return true; 34 } 35 36 function _meta_no_you_cant( $key, $post_id, $user_id, $cap ) { 37 return false; 38 } 39 32 40 // test the default roles 33 41 34 42 function test_user_administrator() { … … 445 453 // other authors and contributors can't 446 454 $this->assertFalse($author_2->has_cap('delete_post', $post)); 447 455 $this->assertFalse($contributor->has_cap('delete_post', $post)); 456 457 // Test meta authorization callbacks 458 if ( function_exists( 'register_meta') ) { 459 $this->assertFalse( $admin->has_cap('delete_post_meta', '_protected', $post) ); 460 register_meta( '_protected', 'post', array( 'auth_callback' => array( &$this, '_meta_yes_you_can') ) ); 461 $this->assertTrue( $admin->has_cap('delete_post_meta', '_protected', $post) ); 462 $this->assertTrue( $admin->has_cap('delete_post_meta', 'not_protected', $post) ); 463 register_meta( 'not_protected', 'post', array( 'auth_callback' => array( &$this, '_meta_no_you_cant') ) ); 464 $this->assertFalse( $admin->has_cap('delete_post_meta', 'not_protected', $post) ); 465 } 448 466 } 449 467 450 468 function test_page_meta_caps() {