title: PHPUnit: get arguments to a mock method call
body: <p>I'm currently working on a project that stores sensitive data, and must therefore be able to erase them on request.</p>
  
  <p>I'd like to test that my entity (patient) is saved to the database with a null phone number. First idea to do that: get the argument passed to <code>PatientDao::savePatient(PatientModel $patient)</code>, and have a look at its <code>phoneNumber</code> attribute.</p>
  
  <p>So here is the <code>PatientDao</code> interface:</p>
  
  <pre><code>interface PatientDao {
      function savePatient(PatientModel $patient);
  }
  </code></pre>
  
  <p>And the code in my test file:</p>
  
  <pre><code>$this-&gt;patientDao                    // This is my mock
              -&gt;expects($this-&gt;once()) 
              -&gt;method('savePatient'); // savePatient() must be called once
  
  $this-&gt;controller-&gt;handleMessage(...);
  
  $patient = ??; // How can I get the patient to make assertions with it ?
  </code></pre>
  
  <p>How can I do that, or is there any other way to make sure the patient is saved with a null phone number?</p>