GWY
2022-04-27 12b7399736e90d33bfe0c2d29917d6f075246e00
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
@isTest
public with sharing class OrderShippingNotificationControllerTest {
 
    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',
            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),
            ExpectedDeliveryDate__c = Date.today(),
            SalesChannel__c = 'direct'
        );
        insert opp;
 
        Order odr = new Order(
            Name = '',
            Status = 'Draft',
            AccountId = accIE.Id,
            ApproveStatus__c = 'Draft',
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            ShippingNotes__c = '',
            ShippingRecieverEmailAdr__c = ''
        );
        insert odr;
        
         //发货提醒输入画面
        PageReference page = new PageReference('/apex/OrderShippingNotification?raid=' + odr.Id );
        System.Test.setCurrentPage(page);
        
        OrderShippingNotificationController controller = new OrderShippingNotificationController();
        
 
        //取得订单
        Order odr1 = [select Id, Name,ContractCode__c, ShippingNotes__c,ShippingRecieverEmailAdr__c, OppExpectedDeliveryDate__c from Order where Id = :odr.Id];
 
        //初始化
        controller.init();
        System.assertEquals('期望发货日期:' + odr1.OppExpectedDeliveryDate__c, controller.ra.ShippingNotes__c);
        System.assertEquals(odr1.ShippingRecieverEmailAdr__c, controller.ra.ShippingRecieverEmailAdr__c);
        
        
        //发送按钮
        controller.ra.ShippingNotes__c = 'test1';
 
        //保存后
        controller.saveBtn();
 
 
 
    }
 
 
 
}