title: How do you stub a method to return an array
body: <p>I have DocumentService class like this:</p>
  
  <pre><code>namespace App\Services;
  
  use App\Api\StorageServiceInterface;
  
  class DocumentService
  {
  
      private $storageService;
  
      function __construct(StorageServiceInterface $storageService)
      {
          $this-&gt;storageService = $storageService;
      }
  
      public function createFolder(User $user)
      {
          $folderData = $this-&gt;storageService-&gt;createFolder(
              '/Users/' . $user-&gt;email
          );
  
          $user-&gt;folder = $folderData['folder_id'];
          $user-&gt;save();
  
          return $user-&gt;folder;
      }
  }
  </code></pre>
  
  <p>Partial implmentation of the <code>LocalStorageService</code>.</p>
  
  <pre><code>namespace App\Api;
  
  class LocalStorageService implements StorageServiceInterface
  {
      public function createFolder($folder)
      {
          ...
  
          return ['folder_id' =&gt; $folder_id, 'folder_path' =&gt; $folder_path];
      }
  }
  </code></pre>
  
  <p>I'm testing the <code>DocumentService</code> class. I'm trying to mock the <code>createFolder()</code> method on the <code>LocalStorageService</code> which implements <code>StorageServiceInterface</code>. </p>
  
  <p><strong>How do I configure this stub to return the array with PHPUnit?</strong></p>
  
  <p>I've tried this: (partial code from my test)</p>
  
  <pre><code>namespace Tests\Unit\Services;
  
  use App\User;
  use App\Api\LocalStorageService;
  
  public function testCreateFolder()
  {
      $user = factory(User::class)-&gt;make();
  
      $localStorageService = $this-&gt;createMock(LocalStorageService::class);
  
      $localStorageService-&gt;method('createFolder')
              -&gt;willReturn(array('folder_id' =&gt; 'random_id', 'folder_path' =&gt; ("/Users/" . $user-&gt;email)));
  }
  </code></pre>
  
  <p>But I'm only getting <strong>random_id</strong>.</p>