@istest
public class LexConsumableOrderManageControllerTest {
  @IsTest
  static 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;
    }

    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 List<Consumable_order__c>{
        testList1,
        testList2,
        testList3,
        testList4,
        testList5,
        testList6,
        testList7
      };
      LexConsumableOrderManageController.init1();
      String accID = myAccount1.Id;
      LexConsumableOrderManageController.searchConsumableorderdetails(
        '',
        null,
        '',
        accID,
        'ET',
        '北京'
      );
    }
  }
}
