Skip to content

Commit 938bca8

Browse files
committed
Add test testReUpload
1 parent eed9488 commit 938bca8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/FileUploadTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ public function testFailSaveFilePath()
126126
$this->assertEmpty($model->image_path);
127127
}
128128

129+
public function testReUpload()
130+
{
131+
list($file, $model) = $this->uploadFileAndBindToModel([
132+
'modelName' => News::className(),
133+
'attribute' => 'image_path',
134+
'inputName' => 'file-300',
135+
'temporary' => true
136+
]);
137+
138+
$response = $this->runUploadAction([
139+
'modelName' => News::className(),
140+
'attribute' => 'image_path',
141+
'inputName' => 'file-500',
142+
'temporary' => true,
143+
]);
144+
145+
$model->image_path = $response['id'];
146+
$model->save();
147+
148+
$file = File::findOne($response['id']);
149+
$file->setStorage($this->storage);
150+
$this->assertTrue($model->image_path === $file->getStorage()->path());
151+
}
152+
129153
public function testDeleteFile()
130154
{
131155
list($file, $model) = $this->uploadFileAndBindToModel([

0 commit comments

Comments
 (0)