From ba1c90575c47f9cb5c2ce0a20da90d3b1739b5fa Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 26 四月 2022 11:47:45 +0800
Subject: [PATCH] 0425 Commit
---
force-app/main/default/classes/SearchSetProductControllerTest.cls | 143 ++++++++++++++++++++++++++++++-----------------
1 files changed, 92 insertions(+), 51 deletions(-)
diff --git a/force-app/main/default/classes/SearchSetProductControllerTest.cls b/force-app/main/default/classes/SearchSetProductControllerTest.cls
index fa4fdbd..c92ad59 100644
--- a/force-app/main/default/classes/SearchSetProductControllerTest.cls
+++ b/force-app/main/default/classes/SearchSetProductControllerTest.cls
@@ -1,65 +1,106 @@
@isTest
private class SearchSetProductControllerTest {
+
+ @isTest static void test_method_one() {
+ Id pricebookId = Test.getStandardPricebookId();
- static testMethod void myUnitTest() {
-
- Product_Set__c ps = new Product_Set__c();
- Apexpages.Standardcontroller scon = new Apexpages.Standardcontroller(ps);
- SearchSetProductController controller = new SearchSetProductController(scon);
- controller.SearchName = 'aaaa';
- controller.SearchCode = 'bbbb';
- controller.serContact();
- }
-
- static testMethod void initTest() {
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true
+ );
+ insert pricebook;
- Product2 product1 = new Product2( Name='11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(5);
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.ProductCode = 'product1';
+ product1.Product_ECCode__c = 'product1';
+ product1.ProductModels__c = true;
+ product1.ProductStatus__c = '1';
insert product1;
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Applicable_Department__c = '娉屽翱绉�';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- ps1.Invalid_Date__c = date.today().addDays(5);
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ IsActive = true
+ );
+ insert standardPrice1;
- insert psd1;
- //ps1 = [select name,Applicable_Department__c,Product_Set_CD__c,Price_Zero_Count__c,Invalid_Date__c from Product_Set__c where id = :ps1.id];
- //system.assertEquals( '銈汇儍銉堝搧锛�',ps1.name);
- //system.assertEquals( '娉屽翱绉�',ps1.Applicable_Department__c);
- //system.assertEquals( date.today().addDays(5),ps1.Invalid_Date__c);
- //system.assertEquals( '111111',ps1.Product_Set_CD__c);
+ PricebookEntry entry1 = new PricebookEntry(Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
+ entry1.UnitPrice = 0;
+ entry1.IsActive = true;
+ entry1.UseStandardPrice = false;
+ insert entry1;
+ Product_Search__c ps = new Product_Search__c(Product__c = product1.Id);
+
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account user = new Account(
+ Name = '*',
+ FacilityName__c = 'user',
+ PostCode__c = '123456',
+ RecordTypeId = rectIE[0].Id
+ );
+ insert user;
+
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = user.Id,
+ StageName = 'Prospect Created',
+ CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today(),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ ExpectedOrderDate__c = Date.today().addDays(2),
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Machine_Parts__c = 'Machine',
+ Pricebook2Id = pricebook.Id
+ );
+ insert opp;
+ Quote quo = new Quote(
+ Name = 'quo',
+ OpportunityId = opp.Id,
+ SetName1__c = 'setname01',
+ SetQty1__c = 1
+ );
+ insert quo;
+ productSet__c proSet1 = new productSet__c();
+ proSet1.Code__c = 'IXP-7P2';
+ proSet1.Name = 'IXP-7P2';
+ proSet1.IsValid__c = true;
+ proSet1.Name = 'IXP-7P2';
+ insert proSet1;
+
+ productSet__c proSet2 = new productSet__c();
+ proSet2.Code__c = 'IXP-7P1SC';
+ proSet2.Name = 'IXP-7P1SC';
+ proSet2.IsValid__c = true;
+ proSet2.Name = 'IXP-7P1SC';
+ insert proSet2;
+ productSet__c proSet3 = new productSet__c();
+ proSet3.Code__c = 'IXSP-T7LED';
+ proSet3.Name = 'IXSP-T7LED';
+ proSet3.IsValid__c = true;
+ proSet3.Name = 'IXSP-T7LED';
+ insert proSet3;
+ //PageReference page = new PageReference('/apex/SearchProduct?oppId=' + opp.Id + '&val=product1');
+ //PageReference page = new PageReference('/apex/SearchSetProduct?Id=' + quo.Id );
+ PageReference page = new PageReference('/apex/SearchSetProduct?gainQuoteSetNameAndSetQty=IX73鍙屽眰鎵嬪姩%2C2%2C25%3BIX73鍙屽眰缂栫爜鏈烘灦%2C2%2C25%3BIX73鍙屽眰鎵嬪姩%2C2%2C25%3BIX73鍙屽眰缂栫爜鏈烘灦%2C2%2C25');
+ //PageReference page = new PageReference('/apex/SearchSetProduct??gainQuoteSetNameAndSetQty=');
- Apexpages.Standardcontroller scon = new Apexpages.Standardcontroller(ps1);
- SearchSetProductController controller = new SearchSetProductController(scon);
- SearchSetProductController.getlistViewOptions();
+ System.Test.setCurrentPage(page);
+ SearchSetProductController controller = new SearchSetProductController();
controller.init();
- //system.assertEquals( '娑堝寲绉�',controller.listViewOptions.[1]);
- controller.SearchName = '銈汇儍銉堝搧锛�';
- //controller.SearchCode = '111111';
- controller.filterName = '娉屽翱绉�';
+ controller.SearchName = 'IXSP-T7LED';
+ controller.SearchCode = 'IXSP-T7LED';
controller.serContact();
- system.assertEquals( 1,controller.activities.size());
controller.SelectDone();
- }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.1