General Technical Discussions for Service

Get Involved. Join the Conversation.

Topic

    Justin
    Custom Process Model Update Test HarnessAnswered
    Topic posted June 2, 2014 by Justin Red Ribbon: 250+ Points 
    491 Views, 4 Comments
    Title:
    Custom Process Model Update Test Harness
    Content:

    Does anyone have a sample of successfully setting up a test harness to check for the change of a field value when the action is an update? 

    I have tried building a test harness and updating the field I am looking at (contacts.ma_opt_in), but the $object->prev object is always empty.

    Version:
    14.2
    Code Snippet:

    Best Comment

    Mark Rhoads

    The fetchObject() method should return the object or objects in the precise states that are to be tested --- they are passed as-is into the apply() method.

    So, if I want to test the prev, I just add the prev to the object and set the prev values to what I want to test, e.g. for an existing $org (created by either the setup() or fetchObject() method, I might do something like:

    $org->prev = new RNCPHP\Organization;
    $org->prev->Name = "TheFormerName";
    ...
    

     

     

    Comment

     

    • Mark Rhoads

      The fetchObject() method should return the object or objects in the precise states that are to be tested --- they are passed as-is into the apply() method.

      So, if I want to test the prev, I just add the prev to the object and set the prev values to what I want to test, e.g. for an existing $org (created by either the setup() or fetchObject() method, I might do something like:

      $org->prev = new RNCPHP\Organization;
      $org->prev->Name = "TheFormerName";
      ...
      

       

       

    • Justin

      Perfect, that is what I needed to know!  Thanks for your help!

    • Justin

      First off, thanks again @mark.  I was able to create a 10 or 12 test cases in my CPM, and I was able to get them all working.

      However, once I moved on to my next CPM, I ran into another issue that I am hoping someone can shed some light on.

      I need to see if there is a new attachment in this CPM.  My plan was to get the list of file attachments from both the current and previous object and compare the FileNames and their respective UpdateTime fields.  Unfortunately UpdatedTime is a read-only field on the FileAttachmentCommon object, so I cannot set dummy UpdateTimes in the TestHarness and then execute different test cases.  Again, this would only be an issue in the test harness, but I'm a big fan of thoroughly testing my code...

      Any ideas on how I could get around that?

       

       

    • Jaya Lakshmi

      Hi Mark,

      I need to send a mail to contact when the status of Contract(custom object) is expired. While testing in Process designer it works fine and receiving mail for both update and create test cases. But when i try to create a new contract with status expired it doesn't triggers the mail. Please help me to solve this. I have deployed the event handler and also mapped it to contracts object for update/Create. Is there any other mapping to be done?receiving