高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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 class summonsPDFControllerTest {
    static testMethod void summonsPDFControllerTest(){
        Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证'];
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod04 = new Product2(Name='Test04',ProductCode='Test04',Asset_Model_No__c = 'Test04',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod05 = new Product2(Name='Test05',ProductCode='Test05',Asset_Model_No__c = 'Test05',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod06 = new Product2(Name='Test06',ProductCode='Test06',Asset_Model_No__c = 'Test06',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        insert new Product2[] {prod01,prod02,prod03,prod04,prod05,prod06};
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
        Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
        Product2__c pro5 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
        Product2__c pro3 = new Product2__c(Name='Pro004',OT_CODE_Text__c='Test004',Product2__c = prod04.Id);
        Product2__c pro4 = new Product2__c(Name='Pro005',OT_CODE_Text__c='Test005',Product2__c = prod05.Id);
        Product2__c pro6 = new Product2__c(Name='Pro006',OT_CODE_Text__c='Test006',Product2__c = prod06.Id);
        insert new Product2__c[] {pro4, pro5,pro6,pro1, pro2, pro3};
 
        Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id);
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
        insert myAccount1;
        insert myAccount2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
        insert core;
        user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
        insert MyUser_Test;
        system.runAs(MyUser_Test){
 
            Consumable_order__c zsdTest = new Consumable_order__c();
            zsdTest.Name = 'testMing';
            zsdTest.Summons_Sale_Status__c= '批准';
            zsdTest.SummonsStatus_c__c = '草案中';
            zsdTest.SummonsForDirction__c ='二级经销商备货';
            zsdTest.Order_type__c = '订单';
            zsdTest.Dealer_Info__c = myAccount2.id;
            zsdTest.RecordTypeid = System.Label.RT_ConOrder_Order;
            zsdTest.Order_type__c = '传票';
            insert zsdTest;
            Consumable_orderdetails__c Good = new Consumable_orderdetails__c();
            Good.recordtypeid= System.Label.RT_ConOrderDetail1_Order;
            Good.Name = 'ZSD0001';
            Good.Consumable_Product__c = pro1.Id;
            Good.Shipment_Count__c = 1;
            Good.Consumable_order__c = zsdTest.id;
            insert Good;
            Consumable_order_details2__c Orderdet =new Consumable_order_details2__c();
             Orderdet.Name = 'OCM_01_001001';
            Orderdet.Consumable_order_minor__c = zsdTest.Id;
            Orderdet.Bar_Code__c = '11111';
            Orderdet.Arrive_date__c = Date.today();
            Orderdet.Lose_Flag__c = false;
            Orderdet.Send_Date__c = null;
            Orderdet.Used_date__c =null;
            insert Orderdet;
            PageReference page = new PageReference('/apex/summonsPDF?ESetid='+zsdTest.id);
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            summonsPDFController SDF = new summonsPDFController();
            SDF.init();
            system.assertEquals(1, SDF.consumableorderdetailsRecords.size());
        }
    }
}