Changeset 376 in tests
- Timestamp:
- 07/18/2011 08:25:38 PM (13 years ago)
- Location:
- wp-testcase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_meta.php
r374 r376 14 14 } 15 15 16 function _meta_auth_cb() {17 return true;18 }19 20 16 function _meta_sanitize_cb ( $meta_value, $meta_key, $meta_type ) { 21 17 return 'sanitized'; … … 29 25 $this->assertEquals( 'unsanitized', $meta ); 30 26 31 register_meta( 'some_meta', 'post', array( 'sanitize_callback' => array( &$this, '_meta_sanitize_cb' )) );27 register_meta( 'some_meta', 'post', array( &$this, '_meta_sanitize_cb' ) ); 32 28 $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); 33 29 $this->assertEquals( 'sanitized', $meta ); -
wp-testcase/test_user_capabilities.php
r375 r376 30 30 } 31 31 32 function _meta_yes_you_can( $ key, $post_id, $user_id, $cap) {32 function _meta_yes_you_can( $can, $key, $post_id, $user_id, $cap, $caps ) { 33 33 return true; 34 34 } 35 35 36 function _meta_no_you_cant( $ key, $post_id, $user_id, $cap) {36 function _meta_no_you_cant( $can, $key, $post_id, $user_id, $cap, $caps ) { 37 37 return false; 38 } 39 40 function _meta_filter( $meta_value, $meta_key, $meta_type ) { 41 return $meta_value; 38 42 } 39 43 … … 458 462 if ( function_exists( 'register_meta') ) { 459 463 $this->assertTrue( $admin->has_cap('edit_post_meta', $post) ); 460 $this->assertTrue( $admin->has_cap(' create_post_meta', $post) );464 $this->assertTrue( $admin->has_cap('add_post_meta', $post) ); 461 465 $this->assertTrue( $admin->has_cap('delete_post_meta', $post) ); 462 466 463 467 $this->assertFalse( $admin->has_cap('edit_post_meta', $post, '_protected') ); 464 $this->assertFalse( $admin->has_cap(' create_post_meta', $post, '_protected') );468 $this->assertFalse( $admin->has_cap('add_post_meta', $post, '_protected') ); 465 469 $this->assertFalse( $admin->has_cap('delete_post_meta', $post, '_protected') ); 466 470 467 register_meta( '_protected', 'post', array( 'auth_callback' => array( &$this, '_meta_yes_you_can' )) );471 register_meta( '_protected', 'post', array( &$this, '_meta_filter' ), array( &$this, '_meta_yes_you_can' ) ); 468 472 $this->assertTrue( $admin->has_cap('edit_post_meta', $post, '_protected') ); 469 $this->assertTrue( $admin->has_cap(' create_post_meta', $post, '_protected') );473 $this->assertTrue( $admin->has_cap('add_post_meta', $post, '_protected') ); 470 474 $this->assertTrue( $admin->has_cap('delete_post_meta', $post, '_protected') ); 471 475 472 476 $this->assertTrue( $admin->has_cap('edit_post_meta', $post, 'not_protected') ); 473 $this->assertTrue( $admin->has_cap(' create_post_meta', $post, 'not_protected') );477 $this->assertTrue( $admin->has_cap('add_post_meta', $post, 'not_protected') ); 474 478 $this->assertTrue( $admin->has_cap('delete_post_meta', $post, 'not_protected') ); 475 479 476 register_meta( 'not_protected', 'post', array( 'auth_callback' => array( &$this, '_meta_no_you_cant')) );480 register_meta( 'not_protected', 'post', array( &$this, '_meta_filter' ), array( &$this, '_meta_no_you_cant' ) ); 477 481 $this->assertFalse( $admin->has_cap('edit_post_meta', $post, 'not_protected') ); 478 $this->assertFalse( $admin->has_cap(' create_post_meta', $post, 'not_protected') );482 $this->assertFalse( $admin->has_cap('add_post_meta', $post, 'not_protected') ); 479 483 $this->assertFalse( $admin->has_cap('delete_post_meta', $post, 'not_protected') ); 480 484 }
Note: See TracChangeset
for help on using the changeset viewer.