From 5363705f99dcbb7c270a619804beb4ac29b3faa0 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期三, 09 八月 2023 20:02:16 +0800
Subject: [PATCH] 今日修改

---
 force-app/main/default/classes/AttachmentTriggerTest.cls |   42 ++++++++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/force-app/main/default/classes/AttachmentTriggerTest.cls b/force-app/main/default/classes/AttachmentTriggerTest.cls
index 9d39928..b612437 100644
--- a/force-app/main/default/classes/AttachmentTriggerTest.cls
+++ b/force-app/main/default/classes/AttachmentTriggerTest.cls
@@ -8,7 +8,6 @@
 	
 	@isTest 
 	static void test_method_one() {
-
 		List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -66,22 +65,37 @@
         ofile.Opportunity__c = opp.Id;
         ofile.Oppor_File_Stage__c = 'G';
         insert ofile;
-        Attachment att1 = new Attachment(
-            Name = 'test',
-            ParentId = ofile.Id,
-            Body = EncodingUtil.base64Decode('test')
+        ContentVersion version = new ContentVersion(
+            Title = 'test',
+            VersionData = EncodingUtil.base64Decode('test'),
+            ContentLocation = 's',
+            PathOnClient = 'test.txt'
         );
-        System.Test.startTest();
-        insert att1;
-        Attachment att = new Attachment(
-            Name = 'test',
-            ParentId = ofile.Id,
-            Body = EncodingUtil.base64Decode('test')
-        );
-        insert att;
+        insert version;
+        version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
+        ContentDocumentLink link = new ContentDocumentLink();
+        link.ContentDocumentId = version.ContentDocumentId;
+        link.LinkedEntityId = ofile.Id;
+        link.ShareType = 'I';
+        link.Visibility = 'AllUsers';
+        insert link;
+        ContentDocument con = [select Id from ContentDocument where Id =: version.ContentDocumentId];
+        delete con;
+        // Attachment att1 = new Attachment(
+        //     Name = 'test',
+        //     ParentId = ofile.Id,
+        //     Body = EncodingUtil.base64Decode('test')
+        // );
+        // System.Test.startTest();
+        // insert att1;
+        // Attachment att = new Attachment(
+        //     Name = 'test',
+        //     ParentId = ofile.Id,
+        //     Body = EncodingUtil.base64Decode('test')
+        // );
+        // insert att;
         
         //delete att1;
-        System.Test.stopTest();
 	}
 	
 	//@isTest 

--
Gitblit v1.9.1