Testing it can update (rename) a child folder too

parent 69192d8c
......@@ -48,7 +48,7 @@ class EloquentFolderRepository extends EloquentBaseRepository implements FolderR
'filename' => array_get($data, 'name'),
'path' => $this->getPath($data),
];
dd($previousData, $formattedData);
event($event = new FolderIsUpdating($formattedData));
$model->update($event->getAttributes());
......
......@@ -126,6 +126,18 @@ final class EloquentFolderRepositoryTest extends MediaTestCase
$this->assertEquals('/assets/media/new-name', $folder->path->getRelativeUrl());
}
/** @test */
public function it_can_update_sub_folder_in_database()
{
$folder = $this->folder->create(['name' => 'My Folder', 'parent_id' => 0]);
$folderTwo = $this->folder->create(['name' => 'Child Folder', 'parent_id' => $folder->id]);
$folderTwo = $this->folder->update($folderTwo, ['name' => 'Awesome Child', 'parent_id' => $folder->id]);
$this->assertEquals('Awesome Child', $folderTwo->filename);
$this->assertEquals('/assets/media/my-folder/awesome-child', $folderTwo->path->getRelativeUrl());
}
/** @test */
public function it_triggers_event_when_folder_was_updated()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment