19626
2023-08-09 5363705f99dcbb7c270a619804beb4ac29b3faa0
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