@isTest
|
private class Event_CommentControllerTest {
|
|
private static Event__c e{get;set;}
|
private static User u1{get;set;}
|
private static User u2{get;set;}
|
private static User u3{get;set;}
|
private static User u4{get;set;}
|
|
/**
|
* 初期処理.
|
*/
|
private static void init() {
|
Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
u1 = new User(Test_staff__c = true);
|
u1.LastName = '_サンブリッジ';
|
u1.FirstName = 'あ';
|
u1.Alias = 'あ';
|
u1.Email = 'olympusTest01@sunbridge.com';
|
u1.Username = 'olympusTest01@sunbridge.com';
|
u1.CommunityNickname = 'olympusTest01@sunbridge.com';
|
u1.IsActive = true;
|
u1.EmailEncodingKey = 'ISO-2022-JP';
|
u1.TimeZoneSidKey = 'Asia/Tokyo';
|
u1.LocaleSidKey = 'ja_JP';
|
u1.LanguageLocaleKey = 'ja';
|
u1.ProfileId = p.id;
|
u1.Job_Category__c = '销售服务';
|
u1.Province__c = '東京';
|
u1.Post__c = '部长';
|
insert u1;
|
|
u2 = new User(Test_staff__c = true);
|
u2.LastName = '_サンブリッジ';
|
u2.FirstName = 'あ';
|
u2.Alias = 'あ';
|
u2.Email = 'olympusTest02@sunbridge.com';
|
u2.Username = 'olympusTest02@sunbridge.com';
|
u2.CommunityNickname = 'olympusTest02@sunbridge.com';
|
u2.IsActive = true;
|
u2.EmailEncodingKey = 'ISO-2022-JP';
|
u2.TimeZoneSidKey = 'Asia/Tokyo';
|
u2.LocaleSidKey = 'ja_JP';
|
u2.LanguageLocaleKey = 'ja';
|
u2.ProfileId = p.id;
|
u2.Job_Category__c = '销售服务';
|
u2.Province__c = '東京';
|
u2.Post__c = '经理';
|
insert u2;
|
|
u3 = new User(Test_staff__c = true);
|
u3.LastName = '_サンブリッジ';
|
u3.FirstName = 'あ';
|
u3.Alias = 'あ';
|
u3.Email = 'olympusTest03@sunbridge.com';
|
u3.Username = 'olympusTest03@sunbridge.com';
|
u3.CommunityNickname = 'olympusTest03@sunbridge.com';
|
u3.IsActive = true;
|
u3.EmailEncodingKey = 'ISO-2022-JP';
|
u3.TimeZoneSidKey = 'Asia/Tokyo';
|
u3.LocaleSidKey = 'ja_JP';
|
u3.LanguageLocaleKey = 'ja';
|
u3.ProfileId = p.id;
|
u3.Job_Category__c = '销售服务';
|
u3.Province__c = '東京';
|
u3.Post__c = '';
|
insert u3;
|
|
u4 = new User(Test_staff__c = true);
|
u4.LastName = '_サンブリッジ';
|
u4.FirstName = 'あ';
|
u4.Alias = 'あ';
|
u4.Email = 'olympusTest04@sunbridge.com';
|
u4.Username = 'olympusTest04@sunbridge.com';
|
u4.CommunityNickname = 'olympusTest04@sunbridge.com';
|
u4.IsActive = true;
|
u4.EmailEncodingKey = 'ISO-2022-JP';
|
u4.TimeZoneSidKey = 'Asia/Tokyo';
|
u4.LocaleSidKey = 'ja_JP';
|
u4.LanguageLocaleKey = 'ja';
|
u4.ProfileId = p.id;
|
u4.Job_Category__c = '销售服务';
|
u4.Province__c = '東京';
|
u4.Post__c = '副总监';
|
insert u4;
|
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.today();
|
dr.Reporter__c = Userinfo.getUserId();
|
insert dr;
|
|
Datetime dt = Datetime.now();
|
e = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = dt,
|
DurationInMinutes__c = 60,
|
EndDateTime__c = dt.addMinutes(60),
|
ActivityDate__c = Date.today(),
|
Daily_Report__c = dr.Id
|
);
|
insert e;
|
}
|
|
static testMethod void myUnitTest() {
|
init();
|
|
System.runAs(u1) {
|
PageReference pageRef = Page.EventComment;
|
pageRef.getParameters().put('Id', e.id);
|
Test.setCurrentPage(pageRef);
|
|
Event_CommentController ec = new Event_CommentController();
|
ec.save();
|
}
|
|
System.runAs(u2) {
|
PageReference pageRef = Page.EventComment;
|
pageRef.getParameters().put('Id', e.id);
|
Test.setCurrentPage(pageRef);
|
|
Event_CommentController ec = new Event_CommentController();
|
ec.save();
|
}
|
|
System.runAs(u3) {
|
PageReference pageRef = Page.EventComment;
|
pageRef.getParameters().put('Id', e.id);
|
Test.setCurrentPage(pageRef);
|
|
Event_CommentController ec = new Event_CommentController();
|
ec.save();
|
}
|
|
System.runAs(u4) {
|
PageReference pageRef = Page.EventComment;
|
pageRef.getParameters().put('Id', e.id);
|
Test.setCurrentPage(pageRef);
|
|
Event_CommentController ec = new Event_CommentController();
|
ec.save();
|
}
|
}
|
}
|