function test1()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $this->checkGroupInTest1($groupRepo->loadById($group->getId()));
     $this->checkGroupInTest1($groupRepo->loadBySlug($site, $group->getSlug()));
     $grb = new GroupRepositoryBuilder();
     $grb->setFreeTextsearch('test');
     $this->assertEquals(1, count($grb->fetchAll()));
     $grb = new GroupRepositoryBuilder();
     $grb->setFreeTextsearch('cats');
     $this->assertEquals(0, count($grb->fetchAll()));
 }
 function onThisStepSetUpPageView()
 {
     $out = array('groupSearchText' => $this->request->request->get('groupsearch'));
     if ($this->request->request->get('action') == 'groupsearch') {
         $grb = new GroupRepositoryBuilder();
         $grb->setSite($this->site);
         $grb->setIncludeDeleted(false);
         $grb->setFreeTextsearch($this->request->request->get('groupsearch'));
         $grb->setLimit(100);
         $out['groups'] = $grb->fetchAll();
     }
     return $out;
 }
 function json(Request $request, Application $app)
 {
     $groupRepoBuilder = new GroupRepositoryBuilder();
     $groupRepoBuilder->setSite($app['currentSite']);
     if (isset($_GET['search']) && trim($_GET['search'])) {
         $groupRepoBuilder->setFreeTextsearch($_GET['search']);
     }
     if (isset($_GET['includeDeleted'])) {
         if (in_array(strtolower($_GET['includeDeleted']), array('yes', 'on', '1'))) {
             $groupRepoBuilder->setIncludeDeleted(true);
         } else {
             if (in_array(strtolower($_GET['includeDeleted']), array('no', 'off', '0'))) {
                 $groupRepoBuilder->setIncludeDeleted(false);
             }
         }
     }
     $out = array();
     foreach ($groupRepoBuilder->fetchAll() as $group) {
         $out[] = array('slug' => $group->getSlug(), 'title' => $group->getTitle());
     }
     $response = new Response(json_encode(array('data' => $out)));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }