Пример #1
0
 public function actionDeletecomment($id)
 {
     //if(!Yii::$app->user->isGuest && Yii::$app->user->identity->role == 'admin'){
     CommentsActiveRecord::findOne($id)->delete();
     //}
     //return $this->goBack();
 }
Пример #2
0
 public function testDeleteComment()
 {
     $count1 = CommentsActiveRecord::find()->count();
     $comment = new CommentsActiveRecord();
     $comment->userId = 1;
     $comment->photoId = 0;
     $comment->body = 'comment';
     $comment->created = date("Y-m-d H-i-s");
     $comment->save();
     $controller = new SiteController();
     $controller->actionDeletecomment($comment->id);
     $count2 = CommentsActiveRecord::find()->count();
     //$this->assert($count1, $count2, 'count before inserting and after deleting are not equals');
     if ($count1 != $count2) {
         $this->fire('Test deleting error', new TestEvent($this));
     }
 }