• Jacob Riff
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
For some reason this fails - q.QuoteLineItems is null. Can someone tell me why?
 
@isTest
private class QuoteTest {

   static Account A;
   static Opportunity o;
   static Quote q;
   static Product2 p;
   static PriceBookEntry pe;
   static OpportunityLineItem oli;
   static QuoteLineItem qli;

   static {
       a = new Account(name = 'Test account', Jurisdiction__c = 'Denmark', currencyIsoCode = 'DKK');
       insert a;

       o = new Opportunity(name = 'Test opportunity', AccountId = a.id, closeDate = date.today(), stageName = 'Demonstration Scheduled');
       insert o;

       p = new Product2(name = 'Test product', type__c = 'Subscription', limits__c='a;b\nc;d');
       insert p;

       Id pbId = Test.getStandardPricebookId();

       pe = new PriceBookEntry(PriceBook2Id = pbId, Product2Id = p.id, UnitPrice = 100, IsActive = true);
       insert pe;

       oli = new OpportunityLineItem(OpportunityId = o.id, Quantity = 1, PricebookEntryId = pe.id, totalPrice = 200);
       insert oli;

       q = new Quote(name = 'Test quote', OpportunityId = o.id, PriceBook2Id = pbId);
       insert q;

       qli = new QuoteLineItem(QuoteId = q.id, PriceBookentryId = pe.Id, Quantity = 1, UnitPrice = 1);
       insert qli; 
       System.debug(q);
       System.debug(qli);
       System.debug(q.QuoteLineItems);
   }

User-added image