Changeset 32523 for trunk/tests/phpunit/tests/post/getPostsByAuthorSql.php
- Timestamp:
- 05/21/2015 06:42:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPostsByAuthorSql.php
r31653 r32523 19 19 $maybe_string = get_posts_by_author_sql( 'non_existent_post_type' ); 20 20 $this->assertContains( '1 = 0', $maybe_string ); 21 } 22 23 public function test_multiple_post_types(){ 24 register_post_type( 'foo' ); 25 register_post_type( 'bar' ); 26 27 $maybe_string = get_posts_by_author_sql( 'foo,bar' ); 28 $this->assertContains( "post_type = 'foo'", $maybe_string ); 29 $this->assertContains( "post_type = 'bar'", $maybe_string ); 30 31 _unregister_post_type( 'foo' ); 32 _unregister_post_type( 'bar' ); 21 33 } 22 34 … … 113 125 wp_set_current_user( $current_user ); 114 126 } 127 128 public function test_user_has_access_only_to_private_posts_for_certain_post_types(){ 129 register_post_type( 'foo', array( 'capabilities' => array( 'read_private_posts' => 'read_private_foo' ) ) ); 130 register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) ); 131 register_post_type( 'baz', array( 'capabilities' => array( 'read_private_posts' => 'read_private_baz' ) ) ); 132 $current_user = get_current_user_id(); 133 $u = $this->factory->user->create( array( 'role' => 'editor' ) ); 134 $editor_role = get_role('editor'); 135 $editor_role->add_cap( 'read_private_baz' ); 136 wp_set_current_user( $u ); 137 138 $maybe_string = get_posts_by_author_sql( 'foo,bar,baz' ); 139 $this->assertNotContains( "post_type = 'foo' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string ); 140 $this->assertNotContains( "post_type = 'bar' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string ); 141 $this->assertContains( "post_type = 'baz' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string ); 142 143 _unregister_post_type( 'foo' ); 144 _unregister_post_type( 'bar' ); 145 _unregister_post_type( 'baz' ); 146 wp_set_current_user( $current_user ); 147 } 115 148 }
Note: See TracChangeset
for help on using the changeset viewer.