/**
  *  Test adding/removing related entities
  *
  *  - save returned true
  *  - updating of related entities was completed without errors
  *  - removed entity is removed from the database
  *  - list of added / modified images equals with the input list
  */
 public function testUpdateModels()
 {
     $model = FakeNewsModel::findOne($this->model->id);
     $images = [];
     foreach ($model->images as $image) {
         $images[] = $image->getAttributes();
     }
     $deletedImage = array_pop($images);
     $images = array_merge($images, [['src' => '/images/image3.png'], ['src' => '/images/image4.png'], ['src' => '/images/image5.png']]);
     $model->images = $images;
     $this->assertTrue($model->save());
     $this->assertTrue($model->isRelationalFinished());
     $this->assertEmpty(FakeFilesModel::findOne($deletedImage['id']));
     $model = FakeNewsModel::findOne($this->model->id);
     $this->assertEquals(array_column($images, 'src'), array_map(function ($model) {
         return $model->src;
     }, $model->images));
 }
 /**
  * @inheritdoc
  */
 protected function tearDown()
 {
     FakeFilesModel::deleteAll();
 }
 /**
  * @return $this
  */
 public function getNews_files()
 {
     return $this->hasMany(FakeFilesModel::className(), ['id' => 'file_id'])->via('newsFiles');
 }