In Apex Unit tests why doesn't the MyConrtoller myCont = new MyController(StandardContoller); call set the current page?
For instance, if I have this page:
<apex:page standardController="DB_Object__c" extensions="MyExtension">
<apex:form id="detail_list">
<apex:detail />
<apex:actionStatus id="readStatus">
<apex:facet name="start">
Loading, please wait...
</apex:facet>
<apex:facet name="stop"><apex:outputPanel >
<apex:commandButton action="{!readData}"
value="Update Data"
rerender="detail_list"
status="readStatus"/>
{!remainingRecords}</apex:outputPanel>
</apex:facet>
</apex:actionStatus>
</apex:form>
</apex:page>
If my unit tests create this:
DB_Object__c dbObj = new DB_Object__c();
dbObj.Name = 'test';
dbObj.Setting = 'aSetting';
insert dbObj;
Test.setCurrentPageReference(Page.Demo);
ApexPages.StandardController sc = new ApexPages.StandardController(dbObj);
MyExtension myExt = new MyExtension(sc);
Why does ApexPages.currentPage().getParameters().get('id'); fail? I have to do:
ApexPages.currentPage().getParameters().put('id',dbObj.id);
What is the point of passing in the dbObj to StandardController if it doesn't do anything with it? Is the intent that you send in a blank object and the extension uses this object? There doesn't seem to be a lot of documentation for StandardControllers and Unit Testing...
Thanks!