title: Mockery to return new object with andReturn
body: <p>I have the following method:</p>
  
  <pre><code>public function getThreads()
  {
      $results = \DB::select(\DB::raw(config('sql.messages.threads')), [$this-&gt;user-&gt;user_id]);
  
      $messagesThreadsModel = app()-&gt;make(MessagesThreadsModel::class);
      $messages = [];
  
      foreach ($results as $r) {
          $message = $messagesThreadsModel-&gt;find($r-&gt;messages_thread_id);
          $message-&gt;unread = $r-&gt;unread;
          $messages[] = $message;
      }
  
      return $messages;
  }
  </code></pre>
  
  <p>To test the above I mock the call \DB::select (via Laravel's facade) to return the list of objects as would the DB class normally do. Then I load message thread model which is once again mocked and replaced in the container (therefore app()->make() will return its mocked instance, not the actual model). </p>
  
  <p>Finally this:</p>
  
  <pre><code>$messagesThreadsModel-&gt;find($r-&gt;messages_thread_id);
  </code></pre>
  
  <p>Is once again mocked to return a dummy object (a stub?). All of it as follows:</p>
  
  <pre><code>$threadsList = $this-&gt;mockThreads();
  
      // mock the raw expression, check the query 
      \DB::shouldReceive('raw')-&gt;once()-&gt;with(m::on(function($sql)
      {
          return strpos($sql, 'messages') !== false;
      }))-&gt;andReturn(true);
  
      // mock the DB call, return a list of objects
      \DB::shouldReceive('select')-&gt;once()-&gt;with(true, [$this-&gt;usersModel-&gt;user_id, $this-&gt;usersModel-&gt;user_id, $this-&gt;usersModel-&gt;user_id])-&gt;andReturn($threadsList);
  
      $mockThreadResult = new \StdClass;
      $mockThreadResult-&gt;last = "date";
  
      $this-&gt;messagesThreadModel-&gt;makePartial();
  
      // HERE IS THE TRICKY PART!
      $this-&gt;messagesThreadModel-&gt;shouldReceive('find')-&gt;times(count($threadsList))-&gt;andReturn($mockThreadResult);
  
      $this-&gt;app-&gt;instance('App\Freemiom\Models\Messages\MessagesThreads', $this-&gt;messagesThreadModel);
  
      $messages = new Messages($this-&gt;usersModel);
      $threadList = $messages-&gt;getThreads();
  </code></pre>
  
  <p>Now what is the problem? Because I pass the dummy object already created, each time in the loop when the ->find method is called the same object is returned. </p>
  
  <p>How should I tell mockery to return a new object with each call? Is it even possible? Or perhaps I should do some code refactoring to make it all testable?</p>