/** * Test admin_disapprove action * * @return void */ public function testAdminDisapproved() { $this->Comments->admin_disapprove('invalid-comment'); $this->assertEqual($this->Comments->redirectUrl, array('action' => 'index')); $this->assertEqual($this->Comments->Session->read('Message.flash.message'), __d('comments', 'Wrong comment id')); $this->Comments->Session->delete('Message.flash.message'); $Article = ClassRegistry::init('Article'); $oldCount = array_shift(Set::extract($Article->read(array('Article.comments'), 1), '/Article/comments')); $this->Comments->admin_disapprove(1); $this->assertEqual($this->Comments->redirectUrl, array('action' => 'index')); $this->assertEqual($this->Comments->Session->read('Message.flash.message'), __d('comments', 'The comment has been disapproved')); $comment = $this->Comments->Comment->read(array('Comment.approved'), 3); $this->assertFalse($comment['Comment']['approved']); $newCount = array_shift(Set::extract($Article->read(array('Article.comments'), 1), '/Article/comments')); $this->assertEqual($newCount, $oldCount - 1); $this->Comments->Session->delete('Message.flash.message'); }