diff --git a/SpacesAPI/File.php b/SpacesAPI/File.php index 59aa070..964a571 100644 --- a/SpacesAPI/File.php +++ b/SpacesAPI/File.php @@ -233,10 +233,12 @@ class File */ public function move(string $newFilename): File { - $newFile = $this->copy($newFilename); + $this->copy($newFilename); $this->delete(); + $this->_filename = $newFilename; + $this->fetchFileInfo(); - return $newFile; + return $this; } /** diff --git a/docs/File.md b/docs/File.md index bdca5b1..3e50692 100644 --- a/docs/File.md +++ b/docs/File.md @@ -301,8 +301,7 @@ public move (string $newFilename) ``` Move or rename a file -The `File` instance on which you call `move` will become invalid and calling methods on it will result in a `FileDoesntExistException` - +The instance of `File` is now the moved object **Parameters** diff --git a/tests/FileTest.php b/tests/FileTest.php index aa5174b..d43bce3 100644 --- a/tests/FileTest.php +++ b/tests/FileTest.php @@ -67,7 +67,7 @@ class FileTest extends TestCase $file = self::$file->copy('test.txt'); $file->move('renamed-file.txt'); - $this->assertEquals("Lorem ipsum", self::$space->file('renamed-file.txt')->getContents()); + $this->assertEquals("renamed-file.txt", $file->filename); $this->expectException(FileDoesntExistException::class); self::$space->file('test.txt');