public function testUpload() { $model = $this->createObject($this->modelClass, ['field' => 'gallery', 'multiple' => true]); $response = $this->runUploadAction(['modelObject' => $model, 'attribute' => 'gallery', 'inputName' => 'file-300']); $this->assertCount(2, $response); $this->assertArrayHasKey('id', $response); $this->assertArrayHasKey('path', $response); $file = File::findOne($response['id']); $this->assertInstanceOf(File::className(), $file); $path = $model->filePath('gallery', $file); $this->assertFileExists($path); }
public function testWrongFilePath() { $model = $this->createObject($this->modelClass); $response = $this->runUploadAction(['modelObject' => $model, 'attribute' => 'image', 'inputName' => 'file-300']); $model->image = $response['id']; $model->save(); $model->image = 'test'; $model->save(); $file = File::findOne($response['id']); $this->assertInstanceOf(File::className(), $file); $this->assertEquals($response['id'], $model->file('image')->id); }