public function addAction()
 {
     $config = $this->getServiceLocator()->get('Config');
     $rbCommentConfig = (object) $config['rb_comment'];
     $form = new CommentForm($rbCommentConfig->strings);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $comment = new Comment();
         $form->setInputFilter($comment->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $comment->exchangeArray($form->getData());
             // Set default visibility from config
             $comment->visible = $rbCommentConfig->default_visibility;
             // If akismet is enabled check for spam
             if ($rbCommentConfig->akismet['enabled'] === true && $this->isSpam($comment, $rbCommentConfig)) {
                 $comment->spam = 1;
                 $comment->visible = 0;
             }
             // We need the id for the mailer
             $comment->id = $this->getCommentTable()->saveComment($comment);
             // Send email if active and not spam
             if ($rbCommentConfig->email['notify'] === true && $comment->spam === 0) {
                 $this->rbMailer($comment);
             }
             return $this->redirect()->toUrl($form->get('uri')->getValue());
         } else {
             $this->flashMessenger()->setNamespace('RbComment');
             $this->flashMessenger()->addMessage(json_encode($form->getMessages()));
             return $this->redirect()->toUrl($form->get('uri')->getValue() . '#rbcomment');
         }
     }
 }
 public function testFormAttributesAreSet()
 {
     $commentForm = new CommentForm($this->formStrings);
     $this->assertEquals('post', $commentForm->getAttribute('method'));
     $this->assertEquals('/rbcomment/add', $commentForm->getAttribute('action'));
 }