• Sunil.Varma
  • NEWBIE
  • 10 Points
  • Member since 2019
  • Response Informatics Ltd.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
I am using a Lightning recordEditForm to display these details. But I want to display this version lookup field as normal Text just like above Type field .
I am using a Lightning recordEditForm to display these details. But I want to display this version lookup field as normal Text just like above Type field .
 
public pagereference payOrder(){
        List<Cart__c> cartList = [Select Id, Name__c, Brands__c,Price__c,Model__c,Image__c from Cart__c];
        List<Order__c> oList = New List<Order__c>();
        for(Cart__c cartOrder : cartList){
            Order__c oOrder = New Order__c();
            oOrder.Name__c =  cartOrder.Name__c;
            oOrder.Model__c =  cartOrder.Model__c;
            oOrder.Brand__c =  cartOrder.Brands__c;
            oOrder.Image__c =  cartOrder.Image__c;
            oOrder.Price__c =  cartOrder.Price__c;
            oList.add(oOrder);
        } 
        Insert oList;
        delete cartList;
        pagereference redirect = new PageReference('/apex/Redirect');
        return redirect;
    }

Can anyone help me out by writing test class for this.Thankyou!!
Apex Method:
public void cartss(){
       Products__c Pro = [Select Id, Name, Brand__c,Deal_Price__c,Model__c,Image__c from Products__c where id =:accId];
     
            Cart__c cartOrder = New Cart__c();
            cartOrder.Name__c =  pro.Name;
            cartOrder.Model__c =  pro.Model__c;
            cartOrder.Brands__c =  pro.Brand__c;
            cartOrder.Image__c =  pro.Image__c;
            cartOrder.Price__c =  pro.Deal_Price__c;
        Insert cartOrder;
        pagereference redirect = new PageReference('/apex/ezshopindex');
    }


Here is my Test class:


 private static testMethod void cartssTest() {
        Category__c cat = new Category__c();
        cat.Name='ss';
        insert cat;
        Sub_Category__c sub = new Sub_Category__c();
        sub.Name='sfdc';
        sub.Category__c=cat.Id;
        insert sub;
        Brands__c br = new Brands__c();
        br.Name='hell';
        br.Sub_Category__c=sub.Id;
        Products__c  testpr = new Products__c();
        testpr.name='testpr';
        testpr.Category__c=cat.Id;
        testpr.Sub_Category__c=sub.Id;
        testpr.Model__c='sfs';
        testpr.Deal_Price__c=8597;
        testpr.Image__c='heloo123';
        testpr.Brand__c=br.Id;
        insert testpr;        
      
        test.startTest();
        PageReference pageRef = Page.ezshopindex;
        SearchInVFController  cart = new SearchInVFController();
        cart.cartss();
        test.stopTest();
    }



Brands__c is lookup for products__c controlling field is Sub_Category__c, 
and Sub_category__c is lookup for products__c and controlling field is Category__c.
Category__c is lookup for Products__c
public pagereference payOrder(){
        List<Cart__c> cartList = [Select Id, Name__c, Brands__c,Price__c,Model__c,Image__c from Cart__c];
        List<Order__c> oList = New List<Order__c>();
        for(Cart__c cartOrder : cartList){
            Order__c oOrder = New Order__c();
            oOrder.Name__c =  cartOrder.Name__c;
            oOrder.Model__c =  cartOrder.Model__c;
            oOrder.Brand__c =  cartOrder.Brands__c;
            oOrder.Image__c =  cartOrder.Image__c;
            oOrder.Price__c =  cartOrder.Price__c;
            oList.add(oOrder);
        } 
        Insert oList;
        delete cartList;
        pagereference redirect = new PageReference('/apex/Redirect');
        return redirect;
    }

Can anyone help me out by writing test class for this.Thankyou!!
Apex Method:
public void cartss(){
       Products__c Pro = [Select Id, Name, Brand__c,Deal_Price__c,Model__c,Image__c from Products__c where id =:accId];
     
            Cart__c cartOrder = New Cart__c();
            cartOrder.Name__c =  pro.Name;
            cartOrder.Model__c =  pro.Model__c;
            cartOrder.Brands__c =  pro.Brand__c;
            cartOrder.Image__c =  pro.Image__c;
            cartOrder.Price__c =  pro.Deal_Price__c;
        Insert cartOrder;
        pagereference redirect = new PageReference('/apex/ezshopindex');
    }


Here is my Test class:


 private static testMethod void cartssTest() {
        Category__c cat = new Category__c();
        cat.Name='ss';
        insert cat;
        Sub_Category__c sub = new Sub_Category__c();
        sub.Name='sfdc';
        sub.Category__c=cat.Id;
        insert sub;
        Brands__c br = new Brands__c();
        br.Name='hell';
        br.Sub_Category__c=sub.Id;
        Products__c  testpr = new Products__c();
        testpr.name='testpr';
        testpr.Category__c=cat.Id;
        testpr.Sub_Category__c=sub.Id;
        testpr.Model__c='sfs';
        testpr.Deal_Price__c=8597;
        testpr.Image__c='heloo123';
        testpr.Brand__c=br.Id;
        insert testpr;        
      
        test.startTest();
        PageReference pageRef = Page.ezshopindex;
        SearchInVFController  cart = new SearchInVFController();
        cart.cartss();
        test.stopTest();
    }



Brands__c is lookup for products__c controlling field is Sub_Category__c, 
and Sub_category__c is lookup for products__c and controlling field is Category__c.
Category__c is lookup for Products__c