/**
  * @group integration
  */
 public function testSearchUserByUsername()
 {
     $this->clearDB();
     $this->createUser();
     $user2 = $this->createUser(true);
     $service = new UserService();
     $foundUsers = $service->searchByUsername($this->standardUser->username, $this->standardUser->username);
     $matchedUser = $foundUsers[0];
     $this->assertEquals($matchedUser->username, $user2->username);
 }
Beispiel #2
0
})->name('social-follow');
// takes current user session and will unfollow :username
$app->delete('/unfollow/:userToUnfollow', function ($userToUnfollow) use($app) {
    UserService::unfollowUser($_SESSION['username'], $userToUnfollow);
    $following = UserService::following($_SESSION['username']);
    $unfollowUrl = $app->urlFor('social-unfollow', array('userToUnfollow' => null));
    $return = array();
    foreach ($following as $friend) {
        $content = array_merge(array('unfollowUrl' => $unfollowUrl), $friend->toArray());
        $return[] = $app->view->getInstance()->render('graphs/social/friends-partial', $content);
    }
    $app->jsonResponse->build(array('following' => $return));
})->name('social-unfollow');
//search users by name
$app->get('/searchbyusername/:search', function ($search) use($app) {
    $users = UserService::searchByUsername($search, $_SESSION['username']);
    $app->jsonResponse->build(array('users' => $users));
})->name('user-search');
// social - show posts
$app->get('/posts', $isLoggedIn, function () use($app) {
    $content = ContentService::getContent($_SESSION['username'], 0);
    $socialContent = array_slice($content, 0, 3);
    $moreContent = count($content) >= 4;
    $app->render('graphs/social/posts.mustache', array('username' => $_SESSION['username'], 'socialContent' => $socialContent, 'moreContent' => $moreContent, 'moreContentUrl' => $app->urlFor('social-feed', array('skip' => null)), 'addContentUrl' => $app->urlFor('social-post-add'), 'friendsUrl' => $app->urlFor('social-friends'), 'postUrl' => $app->urlFor('social-post', array('postId' => null))));
})->name('social-graph');
// social - return posts as JSON
$app->get('/feed/:skip', $isLoggedIn, function ($skip) use($app) {
    $result = ContentService::getContent($_SESSION['username'], (int) $skip);
    $postUrl = $app->urlFor('social-post', array('postId' => null));
    $return = array();
    foreach ($result as $content) {