/**
  * Test admin_ham action
  *
  * @return void
  */
 public function testAdminHam()
 {
     $this->Comments->admin_ham('invalid-comment');
     $this->assertEqual($this->Comments->redirectUrl, array('action' => 'index'));
     $this->assertEqual($this->Comments->Session->read('Message.flash.message'), 'Wrong comment id');
     $this->Comments->Session->delete('Message.flash.message');
     $Article = ClassRegistry::init('Article');
     $oldCount = array_shift(Set::extract($Article->read(array('Article.comments'), 2), '/Article/comments'));
     $this->Comments->admin_ham(3);
     $this->assertEqual($this->Comments->redirectUrl, array('action' => 'index'));
     $this->assertEqual($this->Comments->Session->read('Message.flash.message'), 'Antispam system informed about ham message.');
     $commentFlag = $this->Comments->Comment->read(array('Comment.is_spam'), 3);
     $this->assertEqual($commentFlag['Comment']['is_spam'], 'ham');
     $newCount = array_shift(Set::extract($Article->read(array('Article.comments'), 2), '/Article/comments'));
     $this->assertEqual($newCount, $oldCount + 1);
     $this->Comments->Session->delete('Message.flash.message');
 }
 /**
  * Test admin_ham action
  *
  * @return void
  */
 public function testAdminHam()
 {
     $this->Collection = $this->getMock('ComponentCollection');
     $this->Comments->Session = $this->getMock('SessionComponent', array('setFlash'), array($this->Collection));
     $this->Comments->Session->expects($this->once())->method('setFlash')->with(__d('comments', 'Wrong comment id'));
     $this->Comments->admin_ham('invalid-comment');
     $this->assertEqual($this->Comments->redirectUrl, array('action' => 'index'));
     $Article = ClassRegistry::init('Article');
     $oldCount = array_shift(Set::extract($Article->read(array('Article.comments'), 2), '/Article/comments'));
     $this->Collection = $this->getMock('ComponentCollection');
     $this->Comments->Session = $this->getMock('SessionComponent', array('setFlash'), array($this->Collection));
     $this->Comments->Session->expects($this->any())->method('setFlash')->with(__d('comments', 'Antispam system informed about ham message.'));
     $this->Comments->admin_ham(3);
     $this->assertEqual($this->Comments->redirectUrl, array('action' => 'index'));
     //$this->assertEqual($this->Comments->Session->read('Message.flash.message'), 'Antispam system informed about ham message.');
     $commentFlag = $this->Comments->Comment->read(array('Comment.is_spam'), 3);
     $this->assertEqual($commentFlag['Comment']['is_spam'], 'ham');
     $newCount = array_shift(Set::extract($Article->read(array('Article.comments'), 2), '/Article/comments'));
     $this->assertEqual($newCount, $oldCount + 1);
     $this->Comments->Session->delete('Message.flash.message');
 }