title: Test standard controller - Salesforce
body: <p>I am attempting to test this code. I need to set up the controller and set the parameters. 
  CONTROLLER.</p>
  
  <p>The visualForce page has a standard controller of contact</p>
  
  <pre><code>Public Class myClass{
  public ApexPages.standardController controller  {get; set;}
  public string pid {get; set;}
  
      //CONSTRUCTOR
      public myClass(ApexPages.StandardController controller){
          this.controller = controller;
          pId = ApexPages.CurrentPage().getparameters().get('id');
  }
  </code></pre>
  
  <p>TEST CLASS</p>
  
  <pre><code>@isTest
  public class testMyClass{
  
      static testMethod void myTest(){
          PageReference pageRef = Page.myPage;
      Test.setCurrentPageReference(pageRef);
  
          //create contact
          Contact cont = new Contact(name ='bob');
          insert cont;
  
          ApexPages.CurrentPage().getparameters().put('pid', cont[0].id);
          ApexPages.StandardController sc = new ApexPages.standardController(cont[0]);
          myClass sic = new myClass(sc);
          ApexPages.currentPage().getParameters().put(?);
          System.assertEquals('something here');
      }
  }
  </code></pre>