高章伟
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
@isTest
private class Solution_ProgrammeDeleteControllerTest {
 
    private static User getUser() {
        String timenow = Datetime.now().format('yyyyMMddHHmmss');
        User user1 = new User(Test_staff__c = true, LastName = 'TestMao', FirstName = 'TestMaoF',
                Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com',
                Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
                TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
                ProfileId = System.Label.ProfileId_SystemAdmin,
                Dept__c = '医疗华北营业本部', Job_Category__c = '销售服务', Province__c = '北京');
 
        List<Profile> p = [Select Id From Profile Where Name = '2S1_销售医院担当'];
        System.assertEquals(p.size(), 1);
        System.runAs(new User(Id = Userinfo.getUserId())) {
            insert user1;
        }
        return user1;
    }
 
 
    static testMethod void testMethod1() {
        User user = getUser();
        SolutionProjectRequirements__c solProject = new SolutionProjectRequirements__c();
        solProject.Name = 'Test';
        solProject.HospitalOwner__c = user.Id;
        solProject.Sales_Assistant__c = user.Id;
        solProject.GIR_Assistant__c = user.Id;
        solProject.Project_Type__c = '新建大楼';
        solProject.Purpose_Proposal__c = '促进销售商谈';
        insert solProject;
 
        Solution_Programme__c solProgramme1 =  new Solution_Programme__c();
        solProgramme1.Name = 'test';
        solProgramme1.SolutionProjectRequirements__c = solProject.Id;
        solProgramme1.Business_Promotion__c = user.id;
        insert solProgramme1;
 
        ApexPages.StandardController sp = new ApexPages.standardController( solProgramme1);
        System.Test.startTest();
        Solution_ProgrammeDeleteController  spDC = new Solution_ProgrammeDeleteController(sp);
        spDC.ids = solProgramme1.id;
        spDC.init();
        System.Test.stopTest();
 
    }
}