Skip to content

Commit

Permalink
Fix issue with rename notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Randy Čupić committed Sep 23, 2024
1 parent 0fcdb93 commit 993dc17
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Core/Provider/Cloudinary/CloudinaryRemoteId.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function fromCloudinaryData(array $data, string $folderMode = Clou
return new self(
$data['type'] ?? 'upload',
$data['resource_type'] ?? 'image',
$data['public_id'],
$data['public_id'] ?? $data['to_public_id'],
$folderMode,
);
}
Expand Down
39 changes: 39 additions & 0 deletions tests/lib/Core/Provider/Cloudinary/CloudinaryRemoteIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@ public function testFromCloudinaryData(): void
self::assertNull($remoteId->getFolder());
}

public function testFromCloudinaryDataRenameNotification(): void
{
$data = [
'from_public_id' => 'folder/my_test_image.jpg',
'to_public_id' => 'folder/subfolder/my_test_image_2.jpg',
'resource_type' => 'image',
'type' => 'upload',
'secure_url' => 'https://cloudinary.com/cloudname/upload/image/folder/subfolder/my_test_image_2.jpg',
'size' => 23456,
];

$remoteId = CloudinaryRemoteId::fromCloudinaryData($data);

self::assertSame(
'upload|image|folder/subfolder/my_test_image_2.jpg',
$remoteId->getRemoteId(),
);

self::assertSame(
'folder/subfolder/my_test_image_2.jpg',
$remoteId->getResourceId(),
);

self::assertSame(
'image',
$remoteId->getResourceType(),
);

self::assertSame(
'upload',
$remoteId->getType(),
);

self::assertFolderSame(
Folder::fromPath('folder/subfolder'),
$remoteId->getFolder(),
);
}

public function testFromRemoteId(): void
{
$remoteId = CloudinaryRemoteId::fromRemoteId('private|video|media/videos/my_test_video.mp4');
Expand Down

0 comments on commit 993dc17

Please sign in to comment.