@istest
|
public class ConsumableOrderManagetest {
|
|
static testMethod void ConsumableOrdertest(){
|
User myUser_test = new User();
|
Account myAccount1;
|
Contact core;
|
User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
|
NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
|
insert n;
|
System.runAs(currentUser){
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id );
|
insert myAccount1;
|
core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
|
insert core;
|
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 = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '北京');
|
insert myUser_test;
|
}
|
// Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
// if (rectCo.size() == 0) {
|
// return;
|
// }
|
// Account myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id );
|
// insert myAccount1;
|
// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.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 = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '北京');
|
// insert myUser_test;
|
|
system.runAs(myUser_test){
|
Consumable_order__c testList5 = new Consumable_order__c(Name='test5',Order_status__c='草案中',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_ProType__c = 'ET');
|
Consumable_order__c testList6 = new Consumable_order__c(Name='test6',Order_status__c='已提交',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_ProType__c = 'ET');
|
Consumable_order__c testList7 = new Consumable_order__c(Name='test7',Order_status__c='已提交',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_ProType__c = 'ET');
|
Consumable_order__c testList1 = new Consumable_order__c(Name='test1',Order_status__c='草案中',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_ProType__c = 'ET');
|
Consumable_order__c testList2 = new Consumable_order__c(Name='test2',Order_status__c='草案中',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_ProType__c = 'ET');
|
Consumable_order__c testList3 = new Consumable_order__c(Name='test3',Order_status__c='草案中',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_ProType__c = 'ET');
|
Consumable_order__c testList4 = new Consumable_order__c(Name='test4',Order_status__c='草案中',Dealer_info__c=myAccount1.Id,Order_type__c ='订单',RecordtypeId = System.Label.RT_ConOrder_Order,Order_date__c = Date.today(),Order_ProType__c = 'ET');
|
insert new Consumable_order__c[]{testList1,testList2,testList3,testList4,testList5,testList6,testList7};
|
ConsumableOrderManageController cmc = new ConsumableOrderManageController();
|
cmc.init1();
|
System.assertEquals('test1', cmc.raesList[0].name);
|
System.assertEquals('test2', cmc.raesList[1].name);
|
System.assertEquals('test3', cmc.raesList[2].name);
|
System.assertEquals('test4', cmc.raesList[3].name);
|
System.assertEquals('test5', cmc.raesList[4].name);
|
System.assertEquals('test6', cmc.raesList[5].name);
|
System.assertEquals('test7', cmc.raesList[6].name);
|
cmc.category1='1';
|
cmc.searchConsumableorderdetails();
|
System.assertEquals('test1', cmc.raesList[0].name);
|
cmc.category1=null;
|
cmc.coc.Order_date__c = Date.today();
|
cmc.searchConsumableorderdetails();
|
System.assertEquals('test4', cmc.raesList[0].name);
|
cmc.neworder();
|
cmc.agreementorder();
|
cmc.hospitalorder();
|
cmc.promotionorder();
|
}
|
}
|
}
|