buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@isTest
public with sharing class OpportunityVisitNotesControllerTest {
 
    static testMethod void myTest1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        Account accIE = new Account(
            Name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c='Customer IE',
            FacilityName__c='abc',
            PostCodeD__c='000000',
            PostCode__c='000000'
        );
        insert accIE;
 
        PriceBook2 pricebook =new PriceBook2(
            Name = 'IE'
        );
        insert pricebook;
 
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        // 有预定下单日
        Opportunity opp = new Opportunity(
            Name = 'test opp',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Prospect Created',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            SalesChannel__c = 'direct',
            Visit_Notes__c = ''
            
        );
        insert opp;
 
       
 
         //画面迁移--留言画面
        PageReference page = new PageReference('/apex/OpportunityVisitNotesPopUp?raid=' + opp.Id );
        System.Test.setCurrentPage(page);
 
        OpportunityVisitNotesController controller = new OpportunityVisitNotesController();
 
        //取得询价单
        Opportunity opp1 = [select Id, Name, Visit_Notes__c from Opportunity where Id = :opp.Id];
 
        //初始化
        controller.init1();
        System.assertEquals('', controller.ra1.Visit_Notes__c);
 
        //发送按钮
        controller.ra1.Visit_Notes__c = 'test1';
 
        //保存后
        controller.saveBtn();
 
        // StandardController
        controller = new OpportunityVisitNotesController(new ApexPages.StandardController(opp));
        controller.init();
    }
 
 
 
}