<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][9364] trunk/tests/phpunit/testcases: Unit tests: move tests around so that the top-level tests directory has a folder for each BP component.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/9364">9364</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/9364","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>djpaul</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-01-15 21:17:09 +0000 (Thu, 15 Jan 2015)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Unit tests: move tests around so that the top-level tests directory has a folder for each BP component.</pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestcasescoresuggestionsnonauthphp">trunk/tests/phpunit/testcases/core/suggestions-nonauth.php</a></li>
<li><a href="#trunktestsphpunittestcasescoresuggestionsphp">trunk/tests/phpunit/testcases/core/suggestions.php</a></li>
<li><a href="#trunktestsphpunittestcasesroutingurlphp">trunk/tests/phpunit/testcases/routing/url.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>trunk/tests/phpunit/testcases/apis/</li>
<li>trunk/tests/phpunit/testcases/url/</li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestcasescoresuggestionsnonauthphpfromrev9363trunktestsphpunittestcasesapissuggestionsnonauthphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/testcases/core/suggestions-nonauth.php (from rev 9363, trunk/tests/phpunit/testcases/apis/suggestions-nonauth.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/core/suggestions-nonauth.php                                (rev 0)
+++ trunk/tests/phpunit/testcases/core/suggestions-nonauth.php  2015-01-15 21:17:09 UTC (rev 9364)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,180 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Suggestions API tests specifically for non-authenticated (anonymous) users.
+ *
+ * @group api
+ * @group suggestions
+ */
+class BP_Tests_Suggestions_Non_Authenticated extends BP_UnitTestCase {
+       protected static $group_ids    = array();
+       protected static $group_slugs  = array();
+       protected static $user_ids     = array();
+
+       public static function setUpBeforeClass() {
+               parent::setUpBeforeClass();
+
+               $users = array(
+                       // user_login, display_name
+                       array( 'aardvark',    'Bob Smith' ),
+                       array( 'alpaca red',  'William Quinn' ),
+                       array( 'cat',         'Lauren Curtis' ),
+                       array( 'caterpillar', 'Eldon Burrows' ),
+                       array( 'dog green',   'Reece Thornton' ),
+                       array( 'pig',         'Joshua Barton' ),
+                       array( 'rabbit blue', 'Amber Hooper' ),
+                       array( 'smith',       'Robert Bar' ),
+                       array( 'snake',       'Eleanor Moore' ),
+                       array( 'xylo',        'Silver McFadden' ),
+                       array( 'zoom',        'Lisa Smithy' ),
+               );
+
+               $factory = new BP_UnitTest_Factory();
+
+               // Create some dummy users.
+               foreach( $users as $user_index => $user ) {
+                       $new_user = $factory->user->create( array(
+                               'display_name' => $user[1],
+                               'user_login'   => $user[0],
+                               'user_email'   => "test-$user_index@example.com",
+                       ) );
+
+                       self::$user_ids[ $user[0] ] = $new_user;
+               }
+
+               self::$group_slugs['hidden']  = 'the-maw';
+               self::$group_slugs['public']  = 'the-great-journey';
+               self::$group_slugs['private'] = 'tsavo-highway';
+
+               // Create dummy groups.
+               self::$group_ids['hidden'] = $factory->group->create( array(
+                       'creator_id' => self::$user_ids['xylo'],
+                       'slug'       => self::$group_slugs['hidden'],
+                       'status'     => 'hidden',
+               ) );
+               self::$group_ids['public'] = $factory->group->create( array(
+                       'creator_id' => self::$user_ids['xylo'],
+                       'slug'       => self::$group_slugs['public'],
+                       'status'     => 'public',
+               ) );
+               self::$group_ids['private'] = $factory->group->create( array(
+                       'creator_id' => self::$user_ids['xylo'],
+                       'slug'       => self::$group_slugs['private'],
+                       'status'     => 'private',
+               ) );
+
+               // Add dummy users to dummy hidden groups.
+               groups_join_group( self::$group_ids['hidden'], self::$user_ids['pig'] );
+               groups_join_group( self::$group_ids['hidden'], self::$user_ids['alpaca red'] );
+
+               // Add dummy users to dummy public groups.
+               groups_join_group( self::$group_ids['public'], self::$user_ids['aardvark'] );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['alpaca red'] );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['cat'] );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['smith'] );
+
+               // Add dummy users to dummy private groups.
+               groups_join_group( self::$group_ids['private'], self::$user_ids['cat'] );
+               groups_join_group( self::$group_ids['private'], self::$user_ids['caterpillar'] );
+
+               self::commit_transaction();
+       }
+
+       public static function tearDownAfterClass() {
+               foreach ( self::$group_ids as $group_id ) {
+                       groups_delete_group( $group_id );
+               }
+
+               foreach ( self::$user_ids as $user_id ) {
+                       if ( is_multisite() ) {
+                               wpmu_delete_user( $user_id );
+                       } else {
+                               wp_delete_user( $user_id );
+                       }
+               }
+
+               self::commit_transaction();
+       }
+
+       /**
+        * Tests below this point are expected to fail.
+        */
+
+       public function test_suggestions_with_type_members_and_only_friends() {
+               // only_friends requires authenticated requests
+               $suggestions = bp_core_get_suggestions( array(
+                       'only_friends' => true,
+                       'type'         => 'members',
+                       'term'         => 'smith',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+
+       public function test_suggestions_with_type_groupmembers_and_only_friends() {
+               // only_friends requires authenticated requests
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id'     => self::$group_ids['public'],
+                       'only_friends' => true,
+                       'type'         => 'members',
+                       'term'         => 'smith',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+
+       public function test_suggestions_with_type_groupmembers_hidden() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'pig',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+
+       public function test_suggestions_with_type_groupmembers_private() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'cat',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+
+       public function test_suggestions_with_type_groupmembers_public_and_exclude_group_from_results() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // aardvark, smith.
+
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // zoom
+       }
+
+       public function test_suggestions_with_type_groupmembers_private_and_exclude_group_from_results() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'cat',
+               ) );
+               $this->assertTrue( is_wp_error( $suggestions ) );  // no access to group.
+       }
+
+       public function test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'pig',
+               ) );
+               $this->assertTrue( is_wp_error( $suggestions ) );  // no access to group.
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestcasescoresuggestionsphpfromrev9363trunktestsphpunittestcasesapissuggestionsphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/testcases/core/suggestions.php (from rev 9363, trunk/tests/phpunit/testcases/apis/suggestions.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/core/suggestions.php                                (rev 0)
+++ trunk/tests/phpunit/testcases/core/suggestions.php  2015-01-15 21:17:09 UTC (rev 9364)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,507 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Suggestions API tests for authenticated (logged in) users.
+ *
+ * @group api
+ * @group suggestions
+ */
+class BP_Tests_Suggestions_Authenticated extends BP_UnitTestCase {
+       protected static $current_user = null;
+       protected static $group_ids    = array();
+       protected static $group_slugs  = array();
+       protected static $old_user_id  = 0;
+       protected static $user_ids     = array();
+
+       public static function setUpBeforeClass() {
+               parent::setUpBeforeClass();
+
+               $factory = new BP_UnitTest_Factory();
+
+               self::$old_user_id  = get_current_user_id();
+               self::$current_user = $factory->user->create( array(
+                       'display_name' => 'Katie Parker',
+                       'user_login'   => 'katie',
+                       'user_email'   => 'test-katie@example.com',
+               ) );
+
+               $users = array(
+                       // user_login, display_name
+                       array( 'aardvark',    'Bob Smith' ),
+                       array( 'alpaca red',  'William Quinn' ),
+                       array( 'cat',         'Lauren Curtis' ),
+                       array( 'caterpillar', 'Eldon Burrows' ),
+                       array( 'dog green',   'Reece Thornton' ),
+                       array( 'pig',         'Joshua Barton' ),
+                       array( 'rabbit blue', 'Amber Hooper' ),
+                       array( 'smith',       'Robert Bar' ),
+                       array( 'snake',       'Eleanor Moore' ),
+                       array( 'xylo',        'Silver McFadden' ),
+                       array( 'zoom',        'Lisa Smithy' ),
+               );
+
+               // Create some dummy users.
+               foreach ( $users as $user_index => $user ) {
+                       $new_user = $factory->user->create( array(
+                               'display_name' => $user[1],
+                               'user_login'   => $user[0],
+                               'user_email'   => "test-$user_index@example.com",
+                       ) );
+
+                       self::$user_ids[ $user[0] ] = $new_user;
+               }
+
+               // Create some dummy friendships (but not the corresponding activity items).
+               remove_action( 'friends_friendship_accepted', 'bp_friends_friendship_accepted_activity', 10, 4 );
+               friends_add_friend( self::$current_user, self::$user_ids['aardvark'], true );
+               friends_add_friend( self::$current_user, self::$user_ids['cat'], true );
+               friends_add_friend( self::$current_user, self::$user_ids['caterpillar'], true );
+               friends_add_friend( self::$current_user, self::$user_ids['pig'], true );
+               add_action( 'friends_friendship_accepted', 'bp_friends_friendship_accepted_activity', 10, 4 );
+
+               self::$group_slugs['hidden']  = 'the-maw';
+               self::$group_slugs['public']  = 'the-great-journey';
+               self::$group_slugs['private'] = 'tsavo-highway';
+
+               // Create dummy groups.
+               self::$group_ids['hidden'] = $factory->group->create( array(
+                       'creator_id' => self::$user_ids['xylo'],
+                       'slug'       => self::$group_slugs['hidden'],
+                       'status'     => 'hidden',
+               ) );
+               self::$group_ids['public'] = $factory->group->create( array(
+                       'creator_id' => self::$user_ids['xylo'],
+                       'slug'       => self::$group_slugs['public'],
+                       'status'     => 'public',
+               ) );
+               self::$group_ids['private'] = $factory->group->create( array(
+                       'creator_id' => self::$user_ids['xylo'],
+                       'slug'       => self::$group_slugs['private'],
+                       'status'     => 'private',
+               ) );
+
+               // Add dummy users to dummy hidden groups.
+               groups_join_group( self::$group_ids['hidden'], self::$user_ids['pig'] );
+               groups_join_group( self::$group_ids['hidden'], self::$user_ids['alpaca red'] );
+
+               // Add dummy users to dummy public groups.
+               groups_join_group( self::$group_ids['public'], self::$current_user );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['aardvark'] );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['alpaca red'] );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['cat'] );
+               groups_join_group( self::$group_ids['public'], self::$user_ids['smith'] );
+
+               // Add dummy users to dummy private groups.
+               groups_join_group( self::$group_ids['private'], self::$user_ids['cat'] );
+               groups_join_group( self::$group_ids['private'], self::$user_ids['caterpillar'] );
+
+               self::commit_transaction();
+       }
+
+       public static function tearDownAfterClass() {
+               foreach ( self::$group_ids as $group_id ) {
+                       groups_delete_group( $group_id );
+               }
+
+               foreach ( array_merge( self::$user_ids, array( self::$current_user ) ) as $user_id ) {
+                       if ( is_multisite() ) {
+                               wpmu_delete_user( $user_id );
+                       } else {
+                               wp_delete_user( $user_id );
+                       }
+               }
+
+               self::commit_transaction();
+       }
+
+       public function setUp() {
+               parent::setUp();
+               $this->set_current_user( self::$current_user );
+       }
+
+       public function tearDown() {
+               parent::tearDown();
+               $this->set_current_user( self::$old_user_id );
+       }
+
+       public function test_suggestions_with_type_members() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'type' => 'members',
+                       'term' => 'smith',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 3, count( $suggestions ) );  // aardvark, smith, zoom.
+       }
+
+       public function test_suggestions_with_type_members_and_limit() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'limit' => 2,
+                       'type'  => 'members',
+                       'term'  => 'smith',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // two of: aardvark, smith, zoom.
+       }
+
+       public function test_suggestions_with_type_members_and_only_friends() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'only_friends' => true,
+                       'type'         => 'members',
+                       'term'         => 'smith',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // aardvark.
+
+               $suggestions = bp_core_get_suggestions( array(
+                       'only_friends' => true,
+                       'type'         => 'members',
+                       'term'         => 'cat',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // cat, caterpillar.
+       }
+
+       public function test_suggestions_with_type_members_and_term_as_displayname() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'type' => 'members',
+                       'term' => 'aardvark',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // aardvark.
+       }
+
+       public function test_suggestions_with_type_members_and_term_as_usernicename() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'type' => 'members',
+                       'term' => 'eleanor',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // snake.
+       }
+
+       public function test_suggestions_with_term_as_current_user() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'type' => 'members',
+                       'term' => 'katie',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );
+               $this->assertSame( 'katie', $suggestions[0]->ID );
+       }
+
+
+       public function test_suggestions_with_type_groupmembers_public() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // aardvark, smith.
+       }
+
+       public function test_suggestions_with_type_groupmembers_public_and_limit() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'limit'    => 1,
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // one of: aardvark, smith.
+       }
+
+       public function test_suggestions_with_type_groupmembers_public_and_only_friends() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id'     => self::$group_ids['public'],
+                       'only_friends' => true,
+                       'type'         => 'members',
+                       'term'         => 'smith',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // aardvark.
+       }
+
+       public function test_suggestions_with_type_groupmembers_public_and_term_as_displayname() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'aardvark',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // aardvark.
+       }
+
+       public function test_suggestions_with_type_groupmembers_public_and_term_as_usernicename() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'robert',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // smith.
+       }
+
+       public function test_suggestions_with_type_groupmembers_public_as_id() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // aardvark, smith.
+       }
+
+       public function test_suggestions_with_type_groupmembers_hidden() {
+               // current_user isn't a member of the hidden group
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'pig',
+               ) );
+               $this->assertTrue( is_wp_error( $suggestions ) );
+
+               // "alpaca red" is in the hidden group
+               $this->set_current_user( self::$user_ids['alpaca red'] );
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'pig',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // pig
+       }
+
+       public function test_suggestions_with_type_groupmembers_private() {
+               // current_user isn't a member of the private group.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'cat',
+               ) );
+               $this->assertTrue( is_wp_error( $suggestions ) );
+
+               // "caterpillar" is in the private group
+               $this->set_current_user( self::$user_ids['caterpillar'] );
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'cat',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // cat, caterpillar
+       }
+
+
+       public function test_suggestions_with_type_groupmembers_public_and_exclude_group_from_results() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 2, count( $suggestions ) );  // aardvark, smith.
+
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['public'],
+                       'type'     => 'members',
+                       'term'     => 'smith',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // zoom
+       }
+
+       public function test_suggestions_with_type_groupmembers_private_and_exclude_group_from_results() {
+               // current_user isn't a member of the private group.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'cat',
+               ) );
+               $this->assertTrue( is_wp_error( $suggestions ) );
+
+
+               $this->set_current_user( self::$user_ids['caterpillar'] );
+
+               // "cat" is in the private group, so won't show up here.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'cat',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEmpty( $suggestions );
+
+               // "zoo" is not the private group, so will show up here.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['private'],
+                       'type'     => 'members',
+                       'term'     => 'zoo',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // zoo
+       }
+
+       public function test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results() {
+               // current_user isn't a member of the hidden group.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'pig',
+               ) );
+               $this->assertTrue( is_wp_error( $suggestions ) );
+
+
+               $this->set_current_user( self::$user_ids['alpaca red'] );
+
+               // "alpaca red" is in the hidden group, so won't show up here.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'alpaca red',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEmpty( $suggestions );
+
+               // "zoo" is not the hidden group, so will show up here.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => -self::$group_ids['hidden'],
+                       'type'     => 'members',
+                       'term'     => 'zoo',
+               ) );
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertEquals( 1, count( $suggestions ) );  // zoo
+       }
+
+
+       /**
+        * These next tests check the format of the response from the Suggestions API.
+        */
+
+       public function test_suggestions_response_no_matches() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'term' => 'abcdefghijklmnopqrstuvwxyz',
+                       'type' => 'members',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertInternalType( 'array', $suggestions );
+               $this->assertEmpty( $suggestions );
+       }
+
+       public function test_suggestions_response_single_match() {
+               $suggestion = bp_core_get_suggestions( array(
+                       'term' => 'zoom',
+                       'type' => 'members',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestion ) );
+               $this->assertInternalType( 'array', $suggestion );
+               $this->assertNotEmpty( $suggestion );
+
+               $suggestion = array_shift( $suggestion );
+
+               $this->assertInternalType( 'object', $suggestion );
+               $this->assertAttributeNotEmpty( 'image', $suggestion );
+               $this->assertAttributeNotEmpty( 'ID', $suggestion );
+               $this->assertAttributeNotEmpty( 'name', $suggestion );
+       }
+
+       public function test_suggestions_response_multiple_matches() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'term' => 'cat',
+                       'type' => 'members',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestions ) );
+               $this->assertInternalType( 'array', $suggestions );
+               $this->assertNotEmpty( $suggestions );
+
+               foreach ( $suggestions as $suggestion ) {
+                       $this->assertInternalType( 'object', $suggestion );
+                       $this->assertAttributeNotEmpty( 'image', $suggestion );
+                       $this->assertAttributeNotEmpty( 'ID', $suggestion );
+                       $this->assertAttributeNotEmpty( 'name', $suggestion );
+               }
+       }
+
+       public function test_suggestions_term_is_case_insensitive() {
+               $lowercase = bp_core_get_suggestions( array(
+                       'term' => 'lisa',
+                       'type' => 'members',
+               ) );
+               $this->assertFalse( is_wp_error( $lowercase ) );
+               $this->assertEquals( 1, count( $lowercase ) );
+
+               $uppercase = bp_core_get_suggestions( array(
+                       'term' => 'LISA',
+                       'type' => 'members',
+               ) );
+               $this->assertFalse( is_wp_error( $uppercase ) );
+               $this->assertEquals( 1, count( $uppercase ) );
+
+               $this->assertSame( $lowercase[0]->ID, $uppercase[0]->ID );
+               $this->assertSame( 'zoom', $lowercase[0]->ID );
+       }
+
+       public function test_suggestions_response_property_types() {
+               $suggestion = bp_core_get_suggestions( array(
+                       'term' => 'zoom',
+                       'type' => 'members',
+               ) );
+
+               $this->assertFalse( is_wp_error( $suggestion ) );
+               $this->assertInternalType( 'array', $suggestion );
+               $this->assertNotEmpty( $suggestion );
+
+               $suggestion = array_shift( $suggestion );
+
+               $this->assertInternalType( 'object', $suggestion );
+               $this->assertAttributeInternalType( 'string', 'image', $suggestion );
+               $this->assertAttributeInternalType( 'string', 'ID', $suggestion );
+               $this->assertAttributeInternalType( 'string', 'name', $suggestion );
+       }
+
+
+       /**
+        * Tests below this point are expected to fail.
+        */
+
+       public function test_suggestions_with_bad_type() {
+               $suggestions = bp_core_get_suggestions( array(
+                       'type' => 'fake_type',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+
+       public function test_suggestions_with_type_groupmembers_and_bad_group_ids() {
+               // group_ids can't be a group slug.
+               $suggestions = bp_core_get_suggestions( array(
+                       'group_id' => 'fake-group-slug',
+                       'type'     => 'members',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+
+       public function test_suggestions_with_bad_term() {
+               // a non-empty term is mandatory
+               $suggestions = bp_core_get_suggestions( array(
+                       'term' => '',
+                       'type' => 'members',
+               ) );
+
+               $this->assertTrue( is_wp_error( $suggestions ) );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestcasesroutingurlphpfromrev9363trunktestsphpunittestcasesurlurlphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/testcases/routing/url.php (from rev 9363, trunk/tests/phpunit/testcases/url/url.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/routing/url.php                             (rev 0)
+++ trunk/tests/phpunit/testcases/routing/url.php       2015-01-15 21:17:09 UTC (rev 9364)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,66 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group url
+ */
+class BP_Tests_URL extends BP_UnitTestCase {
+       protected $old_current_user = 0;
+
+       public function setUp() {
+               parent::setUp();
+
+               $this->old_current_user = get_current_user_id();
+               $this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
+       }
+
+       public function tearDown() {
+               parent::tearDown();
+               $this->set_current_user( $this->old_current_user );
+       }
+
+       function test_bp_core_ajax_url() {
+               $forced = force_ssl_admin();
+
+               // (1) HTTPS off
+               force_ssl_admin( false );
+               $_SERVER['HTTPS'] = 'off';
+
+               // (1a) Front-end
+               $this->go_to( '/' );
+               $this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
+
+               // (1b) Dashboard
+               $this->go_to( '/wp-admin' );
+               $this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
+
+               // (2) FORCE_SSL_ADMIN
+               force_ssl_admin( true );
+
+               // (2a) Front-end
+               $this->go_to( '/' );
+               $this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
+
+               // (2b) Dashboard
+               $this->go_to( '/wp-admin' );
+               $this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'https' ) );
+
+               force_ssl_admin( $forced );
+
+               // (3) Multisite, root blog other than 1
+               if ( is_multisite() ) {
+                       $original_root_blog = bp_get_root_blog_id();
+                       $blog_id = $this->factory->blog->create( array(
+                               'path' => '/path' . rand() . time() . '/',
+                       ) );
+                       buddypress()->root_blog_id = $blog_id;
+
+                       $blog_url = get_blog_option( $blog_id, 'siteurl' );
+
+                       $this->go_to( trailingslashit( $blog_url ) );
+                       buddypress()->root_blog_id = $original_root_blog;
+                       $ajax_url = bp_core_ajax_url();
+                       $this->go_to( '/' );
+
+                       $this->assertEquals( $blog_url . '/wp-admin/admin-ajax.php', $ajax_url );
+               }
+       }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>