public function testResizeAndReplace() { extract($this->uploadFile(['modelName' => News::className(), 'attribute' => 'image_path', 'inputName' => 'file-500'])); $thumb = $model->thumb('image_path', '400x400', null, true); $this->assertContains('400x400', $thumb); $this->assertFileNotExists($thumb); $this->checkImageSize($file->path(true), 400, 400); }
public function testRealPath() { extract($this->uploadFile(['modelName' => News::className(), 'attribute' => 'image_path', 'inputName' => 'file-300'])); $this->assertFileExists($model->getFileRealPath('image_path')); }
public function testFailSaveGallery() { extract($this->uploadGallery(['modelName' => News::className(), 'attribute' => 'image_gallery', 'inputName' => 'file-300', 'multiple' => true, 'template' => Yii::getAlias('@tests/data/views/gallery-item.php')])); $oldFiles = $files; $response = $this->runAction(['modelName' => News::className(), 'attribute' => 'image_gallery', 'inputName' => 'file-500']); $file = File::findOne($response['id']); unlink($file->path(true)); $model->image_gallery = ['files' => [$response['id'] => 'test']]; $model->save(); $files = $model->getFiles('image_gallery'); $this->assertCount(0, $files); }