public function postProcess() { // Recherche d'un utilisateur if (Tools::isSubmit('submitSearchAccount')) { $this->setTemplate('comments/search.tpl'); try { $accounts = Github::searchAccounts(Tools::getValue('search', Tools::getValue('term'))); if (Tools::getIsset('term')) { // Depuis ajax $this->renderAjaxSearch($accounts); } $this->context->smarty->assign(array('total_count' => $accounts['total_count'], 'accounts' => $accounts['items'])); } catch (Exception $e) { $this->errors[] = 'Impossible de récupérer les profils correspondant à votre recherche'; } } elseif (Tools::isSubmit('submitAddComment')) { if (!$this->profile) { return $this->errors[] = 'Veuillez specifier un profil valide'; } elseif (!Validate::isNonEmptyString($repository = Tools::getValue('repository'))) { return $this->errors[] = 'Veuillez specifier un nom de dépot valide'; } elseif (!Validate::isCleanHTML($commentContent = Tools::getValue('comment'))) { return $this->errors[] = 'Veuillez fournir un commentaire valide'; } elseif (!$this->isProfileRepository($repository)) { return $this->errors[] = "Ce dépot n'appartient pas à cet utilisateur"; } $comment = new Comment(); $comment->setUser(Auth::getUser())->setUsername($this->profile['login'])->setRepository($repository)->setComment(nl2br($commentContent)); // @todo WYSIWYG if (!$comment->save()) { $this->errors[] = "Impossible d'enregistrer le commentaire (" . Db::getInstance()->getMsgError() . ")"; } else { Flash::success('Votre commentaire a bien été ajouté!'); Tools::redirect($this->context->link->getPageLink('comments', array('user' => $this->profile['login']))); } } }
public function testSearch() { $results = Github::searchAccounts('jessylenne'); $this->assertTrue(Validate::isNonEmptyArray($results)); $this->assertGreaterThanOrEqual(1, $results['total_count']); }