Index: tests/phpunit/tests/url.php
===================================================================
--- tests/phpunit/tests/url.php	(revision 30984)
+++ tests/phpunit/tests/url.php	(working copy)
@@ -279,6 +279,11 @@
 		force_ssl_login( $forced_login );
 	}
 
+	/**
+	 * Test get_adjacent_post returns the next post
+	 *
+	 * @ticket 30287
+	 */
 	function test_get_adjacent_post() {
 		$post_id = $this->factory->post->create();
 		sleep( 1 ); // get_adjacent_post() doesn't handle posts created in the same second.
@@ -312,6 +317,86 @@
 	}
 
 	/**
+	 * Test get_adjacent_post returns the next private post when the author is the currently logged in user.
+	 *
+	 * @ticket 30287
+	 */
+	function test_get_author_private_adjacent_posts() {
+		$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
+		$old_uid = get_current_user_id();
+		wp_set_current_user( $user_id );
+
+		$post_id = $this->factory->post->create( array( 'post_author' => $user_id, 'post_status' => 'private' ) );
+		sleep( 1 ); // get_adjacent_post() doesn't handle posts created in the same second.
+		$post_id2 = $this->factory->post->create( array( 'post_author' => $user_id ) );
+
+		if ( ! isset( $GLOBALS['post'] ) )
+			$GLOBALS['post'] = null;
+		$orig_post = $GLOBALS['post'];
+		$GLOBALS['post'] = get_post( $post_id2 );
+
+		$p = get_adjacent_post();
+		$this->assertInstanceOf( 'WP_Post', $p );
+		$this->assertEquals( $post_id, $p->ID );
+
+		// The same again to make sure a cached query returns the same result
+		$p = get_adjacent_post();
+		$this->assertInstanceOf( 'WP_Post', $p );
+		$this->assertEquals( $post_id, $p->ID );
+
+		// Test next
+		$p = get_adjacent_post( false, '', false );
+		$this->assertEquals( '', $p );
+
+		unset( $GLOBALS['post'] );
+		$this->assertNull( get_adjacent_post() );
+
+		$GLOBALS['post'] = $orig_post;
+		wp_set_current_user( $old_uid );
+
+		// Tests requiring creating more posts can't be run since the query
+		// cache in get_adjacent_post() requires a fresh page load to invalidate.
+	}
+
+	/**
+	 * Test get_adjacent_post excludes the next private post when the author is not the currently logged in user.
+	 *
+	 * @ticket 30287
+	 */
+	function test_get_non_author_private_adjacent_posts() {
+		$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
+		$user_id2 = $this->factory->user->create( array( 'user_login' => 'user-b' ) );
+		$old_uid = get_current_user_id();
+		wp_set_current_user( $user_id2 );
+
+		$post_id = $this->factory->post->create( array( 'post_author' => $user_id, 'post_status' => 'private' ) );
+		sleep( 1 ); // get_adjacent_post() doesn't handle posts created in the same second.
+		$post_id2 = $this->factory->post->create( array( 'post_author' => $user_id2 ) );
+
+		if ( ! isset( $GLOBALS['post'] ) )
+			$GLOBALS['post'] = null;
+		$orig_post = $GLOBALS['post'];
+		$GLOBALS['post'] = get_post( $post_id2 );
+
+		$this->assertEmpty( get_adjacent_post() );
+
+		// The same again to make sure a cached query returns the same result
+		$this->assertEmpty( get_adjacent_post() );
+
+		// Test next
+		$this->assertEmpty( get_adjacent_post( false, '', false ) );
+
+		unset( $GLOBALS['post'] );
+		$this->assertEmpty( get_adjacent_post() );
+
+		$GLOBALS['post'] = $orig_post;
+		wp_set_current_user( $old_uid );
+
+		// Tests requiring creating more posts can't be run since the query
+		// cache in get_adjacent_post() requires a fresh page load to invalidate.
+	}
+
+	/**
 	 * Test that *_url functions handle paths with ".."
 	 *
 	 * @ticket 19032
