Last active
August 20, 2021 11:21
-
-
Save xgeek-net/b96fa1794899f4c31428 to your computer and use it in GitHub Desktop.
ContentDocumentTest Apex TestClass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
private class ContentDocumentTest { | |
private static testMethod void testCreate() { | |
ContentVersion contentVersion_1 = new ContentVersion( | |
Title = 'Penguins', | |
PathOnClient = 'Penguins.jpg', | |
VersionData = Blob.valueOf('Test Content') | |
IsMajorVersion = true | |
); | |
insert contentVersion_1; | |
ContentVersion contentVersion_2 = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion_1.Id LIMIT 1]; | |
List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument]; | |
System.assertEquals(documents.size(), 1); | |
System.assertEquals(documents[0].Id, contentVersion_2.ContentDocumentId); | |
System.assertEquals(documents[0].LatestPublishedVersionId, contentVersion_2.Id); | |
System.assertEquals(documents[0].Title, contentVersion_2.Title); | |
} | |
} |
sfdc-SupportDevelopment
commented
Dec 9, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment