The test class is:
@IsTest
public class ContainerReportTest{
static testMethod void containerReportTest (){
Container__c cont = new Container__c ( Name = 'CMLU', Provenance__c='OTHER', Statut__c='Open');
insert cont;
Articles_Containers__c ac = new Articles_Containers__c();
Product2 p = new Product2(Name ='TestProduct');
insert p;
ac.Product__c=p.ID;
ac.Unit_Weight__c = 45;
ac.Unit_Cost__c = 87;
ac.Container__c= cont.ID;
ac.Number__c = 55;
ac.UM__c ='UNIT(S)';
ac.Local_ID__c = 7888;
ac.Comments__c = 'UNIT(S)';
ac.Purpose__c='Consignment';
ac.Condition__c= 'New';
insert ac;
Account acc = new Account(Name = 'TestACC', Representant__c='TestBene', Departement__c='Ouest', Address__c='102, Test');
insert acc;
Delivery__c del = new Delivery__c();
del.Beneficiaire__c = acc.Id;
del.Ration__c =3;
del.Delivery_status__c='Pending';
insert del;
Item_Distributed__c itemDis = new Item_Distributed__c();
itemDis.Quantity__c = 44;
itemDis.Product__c = ac.Id;
itemDis.Delivery__c =del.Id;
insert itemDis;
ContainerReportController CRC = new ContainerReportController();
}
}
The Controller is:
public class ContainerReportController
{
public Container__c container {get;set;}
public Map<String,List<Item_Distributed__c>> itemDistributed{get;set;}
String containerId;
public ContainerReportController()
{
container = new Container__c();
itemDistributed = new Map<String,List<Item_Distributed__c>>();
try
{
containerId = ApexPages.currentPage().getParameters().get('id');
container = [SELECT Id,Name,DR__c, PO__c,Arrived_Date__c, Invoice__c, Pkl__c, Description__c, Container__c.Provenance__c, Percent_Distributed__c, Bill_of_Lading__c, Size_in_feet__c, Seal_No__c,
(SELECT Id,Name,Prod__c,Number__c,Number_Distributed__c,Available__c,UM__c, Pending__c, Percentagedistributed__c FROM Articles_Containers__r)
FROM Container__c WHERE Id =:containerId];
if(container != null)
{
Set<Id> articleContainersId = new Set<Id>();
if(!container.Articles_Containers__r.isEmpty())
{
for(Articles_Containers__c art :container.Articles_Containers__r)
{
articleContainersId.add(art.Id);
itemDistributed.put(art.Id, new List<Item_Distributed__c>());
}
}
List<Item_Distributed__c> lstItemDistributed = new List<Item_Distributed__c>();
lstItemDistributed = [SELECT Id, Name,Product__c,Quantity__c,Delivery__c,Productt__c, Beneficiary__c, Date__c
FROM Item_Distributed__c WHERE Del_Status__c='Delivered'AND Product__c IN :articleContainersId];
if(!lstItemDistributed.isEmpty())
{
for(Item_Distributed__c item :lstItemDistributed)
{
if(itemDistributed.containsKey(item.Product__c))
{
itemDistributed.get(item.Product__c).add(item);
}
}
}
}
}
catch(Exception e)
{
System.debug(e.getMessage());
}
}
}
What about myControllerExtension testAccPlan = new myControllerExtension(sc);Error: Compile Error: Invalid type: myControllerExtension at line 44 column 3