GWY
2022-04-06 7560140a14a60e949e6130d98225297e84f0a198
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@isTest
private class IENewOpportunityControllerTest {
 
    @isTest static void test_method_one() {
        IENewOpportunityController.asd();
        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',
            PostCode__c = '123456',
            compo_Acc__c = 'COMPO客户'
        );
        insert accIE;
 
        Contact con = new Contact();
        con.LastName = 'test';
        con.AccountId = accIE.Id;
        con.MobilePhone = 'MobilePhoneD__c';
        con.OtherPhone = 'OtherPhoneD__c';
        con.Fax = 'FaxD__c';
        con.Email = 'EmailD__c@test.com';
        con.Phone = 'PhoneD__c';
        con.Title = 'TitleD__c';
        con.Address1__c = 'Address1D__c';
        con.Address2__c = 'Address2D__c';
        con.Address3__c = 'Address3D__c';
        con.Postcode__c = '100111';
        con.ContactStatus__c = 'ContactStatusD__c';
        con.CancelReason__c = 'CancelReasonD__c';
        con.StatusD__c = 'Pass';
 
        insert con;
 
        PriceBook2 pricebook =new PriceBook2(
            Name = 'IE',
            ProductSegment__c = 'IE',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            MachineParts__c = 'Machine'
        );
        insert pricebook;
 
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        // 有预定下单日
        Opportunity opp1 = new Opportunity(
            Name = 'test opp',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Phase3',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            SalesChannel__c = 'direct',
            TradeType__c = 'Taxation'
        );
        insert opp1;
 
        PageReference page = new PageReference('/apex/NewOpportunity?accid=' + accIE.Id + '&conId=' + con.Id);
        System.Test.setCurrentPage(page);
        IENewOpportunityController controller = new IENewOpportunityController();
 
        controller.init();
 
        controller.opp.Name = 'test opp 001';
        controller.opp.TradeType__c = 'Taxation';
        controller.opp.LeadSource = 'Others';
        controller.opp.SalesChannel__c = 'direct';
        controller.opp.Have_Computer__c = true;
        controller.opp.Association_Opportunity__c = opp1.Id;
        controller.saveBtn();
        //system.assertEquals(null,ApexPages.getMessages()[0].getDetail());
 
        controller.saveBtnYes();
 
        controller.saveBtnNo();
    }
 
}