Skip to content

Commit 136d5ed

Browse files
committed
call File::__construct in UploadedFile's constructor
1 parent f6cbac9 commit 136d5ed

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎system/HTTP/Files/UploadedFile.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public function move(string $targetPath, ?string $name = null, bool $overwrite =
165165
$this->path = $targetPath;
166166
$this->name = basename($destination);
167167

168+
parent::__construct($destination, false);
169+
168170
return $this;
169171
}
170172

‎tests/system/HTTP/Files/FileMovingTest.php‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,34 @@ public function testMoved(): void
215215
$this->assertTrue($file->hasMoved());
216216
}
217217

218+
public function testPathnameAfterMoveReflectsTheMovedFile(): void
219+
{
220+
$finalFilename = 'fileA.txt';
221+
service('superglobals')->setFilesArray([
222+
'userfile1' => [
223+
'name' => $finalFilename,
224+
'type' => 'text/plain',
225+
'size' => 124,
226+
'tmp_name' => '/tmp/fileA.txt',
227+
'error' => 0,
228+
],
229+
]);
230+
231+
$collection = new FileCollection();
232+
233+
$destination = $this->destination;
234+
235+
if (! is_dir($destination)) {
236+
mkdir($destination, 0777, true);
237+
}
238+
239+
$file = $collection->getFile('userfile1');
240+
$this->assertInstanceOf(UploadedFile::class, $file);
241+
242+
$file->move($destination, $file->getName(), false);
243+
$this->assertSame($destination . '/' . $finalFilename, $file->getPathname());
244+
}
245+
218246
public function testStore(): void
219247
{
220248
$finalFilename = 'fileA';

‎utils/phpstan-baseline/loader.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 692 errors
1+
# total 689 errors
22

33
includes:
44
- argument.type.neon

‎utils/phpstan-baseline/property.phpDocType.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 22 errors
1+
# total 21 errors
22

33
parameters:
44
ignoreErrors:

0 commit comments

Comments
 (0)