-
-
Save jsmithdev/61234718eb2bbec2e8cdbd8e9a9a82c7 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment