title: Testing if a protected method was called
body: <p>I´m trying to test if a protected method is called in a public interface.</p>
  
  <pre><code>&lt;?php
  abstract class SomeClassAbstract
  { 
      abstract public foo();
  
      public function doStuff() 
      {    
          $this-&gt;_protectedMethod();
      }
  
      protected function _protectedMethod();
      {
          // implementation is irrelevant
      }
  }
  
  &lt;?php
  class MyTest extends PHPUnit_Framework_TestCase
  {
      public function testCalled()
      {
          $mock = $this-&gt;getMockForAbstractClass('SomeClass');
          $mock-&gt;expects($this-&gt;once())
               -&gt;method('_protectedMethod');
  
          $mock-&gt;doStuff();
      }
  }
  </code></pre>
  
  <p>I know it is called correctly, but PHPUnit says its never called.</p>
  
  <p>The same happens when I test the other way, when a method is <strong>never</strong> called:</p>
  
  <pre><code>&lt;?php
  abstract class AnotherClassAbstract
  { 
      abstract public foo();
  
      public function doAnotherStuff() 
      {    
          $this-&gt;_loadCache();
      }
  
      protected function _loadCache();
      {
          // implementation is irrelevant
      }
  }
  
  &lt;?php
  class MyTest extends PHPUnit_Framework_TestCase
  {
      public function testCalled()
      {
          $mock = $this-&gt;getMockForAbstractClass('AnotherClass');
          $mock-&gt;expects($this-&gt;once())
               -&gt;method('_loadCache');
  
          $mock-&gt;doAnotherStuff();
      }
  }
  </code></pre>
  
  <p>The method is called but PHPUnit says that it is not.</p>
  
  <p>What I´m doing wrong?</p>
  
  <p><strong>Edit</strong>
  I wasn´t declaring my methods with double colons, it was just for denoting that it was a public method (interface). Updated to full class/methods declarations.</p>
  
  <p><strong>Edit 2</strong>
  I should have said that I´m testing some method implementations in an abstract class (edited the code to reflect this). Since I can not instantiate the class, how can I test this?</p>
  
  <p>I´m thinking in creating an <code>SomeClassSimple</code> extending <code>SomeClassAbstract</code> and testing this one instead. Is it the right approach?</p>