title: PHPUnit - Assert trait method is called
body: <p>Supposing I have a trait which currently has a method:</p>
  
  <pre><code>trait MyTrait
  {
      public function traitMethod()
      {
          return true;
      }
  }
  </code></pre>
  
  <p>Now let's say this trait is used by several classes but I don't want to write a unit-test for every class.
  Instead I want to write a single unit-test only for the trait:</p>
  
  <pre><code>public function testTraitMethod()
  {
      $trait = $this-&gt;getMockForTrait(MyTrait::class);
      $this-&gt;assertTrue($trait-&gt;traitMethod());
  }
  </code></pre>
  
  <p>But the problem is that a class may actually override trait's method:</p>
  
  <pre><code>class MyClass
  {
      use MyTrait;
  
      public function traitMethod()
      {
          return false;
      }
  }
  </code></pre>
  
  <p>In this case <code>MyClass</code> is doing something wrong but I'm not aware of it since I'm testing only the trait.</p>
  
  <p>My idea would be write a single unit-test for every class just to check if it's using that trait and it's not overriding that method. If a class needs to override trait's method then it needs a specific unit-test as well.</p>
  
  <p>Currently I'm writing unit-tests for each class that implements my trait but it's of course kind of copy-paste tests everywhere.</p>
  
  <p>So is there a way to test if a class calls it's underlying trait method?</p>