title: Getting 'Method was expected to be called 1 times, actually called 0 times.' while testing in Symfony
body: <p>I need a small help with a simple test. I'm trying to test blog post delete endpoint where it deletes both the post and its comments. In the postController method, it calls two other methods from two other repositories (postRepository and commentsRepository) to delete the post completely. Here's how the method in the controller looks like:</p>
  <pre><code>public function deletePost(Request $request, $postId)
  {
      $this-&gt;postRepository()-&gt;deletePost($postId);
      $this-&gt;commentsRepository()-&gt;deleteComments($postId);
  
      return $this-&gt;response(new JsonResponse('', 204));
  }
  </code></pre>
  <p>I only need to check if deletePost method and deleteComments are being called once. Right now I'm getting this:</p>
  <pre><code>Expectation failed for method name is &quot;deletePost&quot; when invoked 1 time(s).
  Method was expected to be called 1 times, actually called 0 times.
  </code></pre>
  <p>Same as deleteComments. Now I feel like the mock is not working properly.
  Here's postRepository's deletePost method and commentRepository's deleteComments method:</p>
  <pre><code>// postRepository's
  public function deletePost($postId)
  {
      // ... some code 
  }
  
  // commentsRepository
  public function deleteComments($postId)
  {
      // ... some code 
  }
  </code></pre>
  <p>Here's the test:</p>
  <pre><code>public function testDelete()
  {
      $post = $this-&gt;postRepository()
        -&gt;findOne(['id' =&gt; PostDataSeeder::POST_ID]);
  
      $route = $this-&gt;getUrl('api_delete_post', [
        '_format' =&gt; 'json',
        'postId' =&gt; $post-&gt;getId()
      ]);
  
      $this-&gt;client-&gt;request('DELETE', $route, [], [], [
        'CONTENT_TYPE' =&gt; 'application/json',
      ]);
  
      // check if deletePost method in postRepository is being called
      $postRepositoryMock = $this-&gt;createMock(PostRepository::class);
      $postRepositoryMock
        -&gt;expects($this-&gt;once())
        -&gt;method('deletePost')
        -&gt;with($post-&gt;getId());
  
      // check if deleteComments method in commentsRepository is being called
      $commentsRepositoryMock = $this-&gt;createMock(CommentsRepository::class);
      $commentsRepositoryMock
        -&gt;expects($this-&gt;once())
        -&gt;method('deleteComments')
        -&gt;with($post-&gt;getId());
  }
  </code></pre>
  <p>This is the minimal representation of my actual code. Everything works perfectly, except the test. Please help me how to test that.</p>