public function testDeletePhoto() { $count1 = PhotoActiveRecord::find()->count(); $photo = new PhotoActiveRecord(); $photo->userId = 1; $photo->photo = file_get_contents("./web/img/user.png"); $photo->posted = date("Y-m-d H-i-s"); $photo->save(); $controller = new SiteController(); $controller->actionDeleteimage($photo->id); $count2 = PhotoActiveRecord::find()->count(); //$this->assert($count1, $count2, 'count before inserting and after deleting are not equals'); if ($count1 != $count2) { $this->fire('Photo deleting error', new TestEvent($this)); } }
public function actionDeleteimage($id) { //if(!Yii::$app->user->isGuest && Yii::$app->user->identity->role == 'admin'){ PhotoActiveRecord::findOne($id)->delete(); //} //return $this->goBack(); }