Changeset 34447
- Timestamp:
- 09/22/2015 09:00:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r34091 r34447 1018 1018 } 1019 1019 } 1020 1021 /** 1022 * @ticket 17253 1023 */ 1024 function test_cpt_with_page_capability_type() { 1025 1026 register_post_type( 'page_capability', array( 1027 'capability_type' => 'page', 1028 ) ); 1029 1030 $cpt = get_post_type_object( 'page_capability' ); 1031 1032 $admin = $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ); 1033 $editor = $this->factory->user->create_and_get( array( 'role' => 'editor' ) ); 1034 $author = $this->factory->user->create_and_get( array( 'role' => 'author' ) ); 1035 $contributor = $this->factory->user->create_and_get( array( 'role' => 'contributor' ) ); 1036 1037 $this->assertEquals( 'edit_pages', $cpt->cap->edit_posts ); 1038 $this->assertTrue( user_can( $admin->ID, $cpt->cap->edit_posts ) ); 1039 $this->assertTrue( user_can( $editor->ID, $cpt->cap->edit_posts ) ); 1040 $this->assertFalse( user_can( $author->ID, $cpt->cap->edit_posts ) ); 1041 $this->assertFalse( user_can( $contributor->ID, $cpt->cap->edit_posts ) ); 1042 1043 $admin_post = $this->factory->post->create_and_get( array( 1044 'post_author' => $admin->ID, 1045 'post_type' => 'page_capability', 1046 ) ); 1047 1048 $this->assertTrue( user_can( $admin->ID, 'edit_post', $admin_post->ID ) ); 1049 $this->assertTrue( user_can( $editor->ID, 'edit_post', $admin_post->ID ) ); 1050 $this->assertFalse( user_can( $author->ID, 'edit_post', $admin_post->ID ) ); 1051 $this->assertFalse( user_can( $contributor->ID, 'edit_post', $admin_post->ID ) ); 1052 1053 $author_post = $this->factory->post->create_and_get( array( 1054 'post_author' => $author->ID, 1055 'post_type' => 'page_capability', 1056 ) ); 1057 1058 $this->assertTrue( user_can( $admin->ID, 'edit_post', $author_post->ID ) ); 1059 $this->assertTrue( user_can( $editor->ID, 'edit_post', $author_post->ID ) ); 1060 $this->assertFalse( user_can( $author->ID, 'edit_post', $author_post->ID ) ); 1061 $this->assertFalse( user_can( $contributor->ID, 'edit_post', $author_post->ID ) ); 1062 1063 _unregister_post_type( 'page_capability' ); 1064 1065 } 1066 1020 1067 }
Note: See TracChangeset
for help on using the changeset viewer.