I was hopping to be able to remove the @seeAllData
annotation from my tests by using Summer'14's addition - Test.getStandardPricebookId()
but the test are failing with this error:
System.DmlException: Update failed. First exception on row 0 with id 0064E000003zx4hQAA; first error: INVALID_OPERATION, This quote can't be synced because it has an inactive or archived price book.: []
The error occurs because the test's set up is trying to set a quote created with the pricebook id obtained from the method as a synced quote. Am I doomed to revert to my seeAlldata version?
I can't put code in comments. I have 2K lines of test class that test syncing custom fields on quote/quote lines and opportunity/opportunity lines.
This is more or less how each test looks like
IdstdPriceBookId = Test.getStandardPricebookId();
Opportunity opp = new Opportunity(Name='test', TotalOpportunityQuantity=10, StageName='Hot', CloseDate=System.today(), Pricebook2Id=stdPriceBookId, AccountId=acc.Id);
Quote quote = new Quote(Name='test', OpportunityId=opp.Id, Pricebook2Id=opp.Pricebook2Id);
private static void startSync(String oppId, String quoteId) {
Opportunity opp = [SELECT SyncedQuoteId FROM Opportunity where Id = :oppId];
opp.SyncedQuoteId = quoteId;
update(opp); <--error trhown
}