liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
@isTest
private class lexSubAuthorizedButtonControllerTest {
    public static Account account1 = new Account();
    public static Account account2 = new Account();
    public static Contact contact1 = new Contact();
    public static Contact contact2 = new Contact();
    static testMethod void testMethod1() {
        lexSubAuthorizedButtonController.init('123');
        List<user> userList = new List<user>();
        Profile p = [select Id from Profile where Name = '系统管理员'];
        UserRole ur = [ SELECT Id, Name FROM UserRole where Name = 'OCSM SFDC管理员'];
        UserRole urtop = [ SELECT Id, Name FROM UserRole where Name = '总经理'];
        string userinfoId = UserInfo.getUserId();
        User tempUser = [select id from user where id = : userinfoId];
        User user1 = new User(Test_staff__c = true, LastName = 'hp',
                              FirstName = 'owner', Alias = 'hp',
                              CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com',
                              Username = 'olympus_hpowner@sunbridge.com', IsActive = true,
                              EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo',
                              LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja');
        user1.ProfileId = p.Id;
        user1.UserRoleId  = ur.id;
        User user2;
        User user3;
        system.runAs(tempUser) {
            userList.add(user1);
            user2 = new User(Test_staff__c = true, LastName = 'hp',
                             FirstName = 'owner', Alias = 'hp',
                             CommunityNickname = 'hpOwner1', Email = '2olympus_hpowner@sunbridge.com',
                             Username = '2olympus_hpowner@sunbridge.com', IsActive = true,
                             EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo',
                             LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja');
            user2.ProfileId = p.Id;
            user2.UserRoleId  = urtop.id;
        }
        system.runAs(user1) {
            SubAuthorized__c tempSubAuthor = new SubAuthorized__c();
            tempSubAuthor.Status__c  = '已批准';
            tempSubAuthor.AuthorizedStartDate__c = Date.today().adddays(1);
            tempSubAuthor.AuthorizedEndDate__c = Date.today().adddays(2);
            tempSubAuthor.Authorizee__c = user2.id;
            tempSubAuthor.Authorizer__c = user1.id;
            insert tempSubAuthor;
            lexSubAuthorizedButtonController.init(tempSubAuthor.Id);
            lexSubAuthorizedButtonController.updateStatuById(tempSubAuthor.Id);
            lexSubAuthorizedButtonController.updateStatuById('xxx123xxx');
        }
        system.debug('test!!');
       
    }
}