I have a small visual force page which displays the oppotunity info. the controller class has a method "GetOppQuery()". In my sandbox i have total 19 opportunities. when i am running the test, the query inside "GetOppQuery()" method is returning zero rows. can some one please have a look? what is wrong with my code?
public with sharing class BPO1
{
Id currentUser = UserInfo.getUserId();
Double M0_amount = 0;
Double M1A_amount = 0;
Double M2_amount = 0;
Double M3_amount = 0;
Double M4_amount = 0;
Double M5_amount = 0;
Double M6A_amount = 0;
Double M6B_amount = 0;
Double M7_amount = 0;
Double M0_count = 0;
Double M1A_count = 0;
Double M2_count = 0;
Double M3_count = 0;
Double M4_count = 0;
Double M5_count = 0;
Double M6A_count = 0;
Double M6B_count = 0;
Double M7_count = 0;
Double MTD_Wins_amount = 0;
Double MTD_Wins_count = 0;
Double YTD_Wins_amount = 0;
Double YTD_Wins_count = 0;
public Integer GetOppQuery()
{
Opportunity[] opps1 = [Select Id, OwnerId, StageName, CloseDate, Amount From Opportunity ];
for ( Opportunity opp : opps1)
{
if (opp.StageName == 'M0 - New Opportunity')
{
M0_amount = M0_amount + opp.Amount;
M0_count = M0_count + 1;
}
if (opp.StageName == 'M1A - Prospect')
{
M1A_amount = M1A_amount + opp.Amount;
M1A_count = M1A_count + 1;
}
if (opp.StageName == 'M2 - Advocate')
{
M2_amount = M2_amount + opp.Amount;
M2_count = M2_count + 1;
}
if (opp.StageName == 'M3 - Power Advocate')
{
M3_amount = M3_amount + opp.Amount;
M3_count = M3_count + 1;
}
if (opp.StageName == 'M4 - Proof Of Capabilities Accepted')
{
M4_amount = M4_amount + opp.Amount;
M4_count = M4_count + 1;
}
if (opp.StageName == 'M5 - Cost Accepted')
{
M5_amount = M5_amount + opp.Amount;
M5_count = M5_count + 1;
}
if (opp.StageName == 'M6A - Verbal Approval')
{
M6A_amount = M6A_amount + opp.Amount;
M6A_count = M6A_count + 1;
}
if (opp.StageName == 'M6B - Stalled')
{
M6B_amount = M6B_amount + opp.Amount;
M6B_count = M6B_count + 1;
}
if (opp.StageName == 'M7 - Closed Won')
{
if (opp.CloseDate.month() == system.today().month())
{
MTD_Wins_amount = MTD_Wins_amount + opp.Amount;
MTD_Wins_count = MTD_Wins_count + 1;
}
M7_amount = M7_amount + opp.Amount;
M7_count = M7_count + 1;
}
}
return opps1.size();
}
}
====test class here====
@isTest
private class BPO1Test {
static testMethod void myUnitTest()
{
// TO DO: implement unit test
BPO1 theBPO = new BPO1();
Integer i = theBPO.GetOppQuery();
System.debug('getOppSize ='+ i);
//System.assertEquals(theBPO.getOppSize() , 18);
}
}
=====debug log=====
13:46:17:010 SOQL_EXECUTE_BEGIN [36]|Aggregations:0|SELECT Id, OwnerId, StageName, CloseDate, Amount FROM Opportunity
13:46:17:012 SOQL_EXECUTE_END [36]|Rows:0
----
13:46:17:000 LIMIT_USAGE_FOR_NS Number of SOQL queries: 1 out of 100
13:46:17:000 LIMIT_USAGE_FOR_NS Number of query rows: 0 out of 50000
can someone please help me? what is wrong with my query?