title: PHPUnit mocked method called 0 times while it should be called once
body: <p>I'm new to unit-testing and I'm having problems understanding the mocking object in phpunit.
  I have the following function:</p>
  
  <pre><code>public function createPaymentStatement()
  {
      $tModel = new \FspInvoice\Model\Transaction();
      $paymentsArr = $this-&gt;transactionGateway-&gt;getTransactionWithStatus($tModel::SETTLED);
      $result = false;
      if(is_array($paymentsArr)){
              //some code here
              $result = $psArr;
  
      }
  
      return $result;
  }
  </code></pre>
  
  <p>And now the uni-test for the function above:</p>
  
  <pre><code> public function testCreatePaymentStatementWithPaymentsSettledReturnsArray()
  {
      $this-&gt;transactionGateway = $this-&gt;getMockBuilder('FspInvoice\Model\TransactionsTable')
          -&gt;setMethods(array('getTransactionWithStatus'))
          -&gt;disableOriginalConstructor()
          -&gt;getMock();
      $this-&gt;transactionGateway-&gt;expects($this-&gt;once())
          -&gt;method('getTransactionWithStatus')
          -&gt;will($this-&gt;returnValue(array(0,1,2)));
      $test = $this-&gt;service-&gt;createPaymentStatement();
      $this-&gt;assertTrue(is_array($test));
  }
  </code></pre>
  
  <p>But when I run the code I get the error:</p>
  
  <pre><code>   1)FspInvoiceTest\ServiceTest\PaymentTest::testCreatePaymentStatementWithPaymentsSettledReturnsArray
  Expectation failed for method name is equal to &lt;string:getTransactionWithStatus&gt; when    invoked 1 time(s).
  Method was expected to be called 1 times, actually called 0 times.
  </code></pre>
  
  <p>What am I doing wrong?</p>