title: How to mock a non-abstract trait method with phpunit?
body: <p>I have a trait (that is used by another trait) with a non-abstract method I need to mock, but when I  try to do so I get the error message:</p>
  
  <blockquote>
    <p>Trying to configure method <code>getOfficeDays</code> which cannot be configured because it does not exist, has not been specified, is final, or is static</p>
  </blockquote>
  
  <p>This is the code I'm trying to test:</p>
  
  <pre><code>trait OfficeDaysTrait {
    public function getOfficeDays(): array {
      // This normally calls the database, that's why I want to mock it in tests
      return [
       [
         'day' =&gt; 'mon',
         'openingTime' =&gt; '08:00:00',
         'closingTime' =&gt; '17:00:00'
       ]
      ];
    }
  }
  
  trait EmployeeAttendenceTrait {
    use OfficeDaysTrait;
  
    public function isLate($today)
    {
       $late = false;
       $officeDays = $this-&gt;getOfficeDays();
  
       // compare logic with today.. whether the employee is late or not
  
       return $late;
    }
  }
  
  </code></pre>
  
  <p>And this is my test method body:</p>
  
  <pre><code>$mock = $this-&gt;getMockForTrait(EmployeeAttendenceTrait::class); 
  
  $mock-&gt;expects($this-&gt;once())
   -&gt;method('getOfficeDays')
   -&gt;will([])
  ;
  
  $this-&gt;assertTrue($mock-&gt;isLate());
  
  </code></pre>
  
  <p>This syntax is based on the example shown in <a href="https://phpunit.de/manual/6.5/en/test-doubles.html" rel="noreferrer">phpunit's documentation for testing traits</a></p>
  
  <p>Why am I getting this error message and how can I mock <code>getOfficeDays</code> to be able to test my <code>isLate</code> method?</p>