title: How to write a test case for phpunit where the code being tested uses optional modules and are not always available
body: <p>I'm just getting into writing testcases and am not sure how to handle certain tests. The classes I'm testing are, in very basic terms, wrappers for various opcode caches. The tests will be bundled into software that will be downloaded and used on many different hosts, thus I'm perplexed as to how to handle testing these classes for two reasons.</p>
  
  <p>Take for example this apc wrapper</p>
  
  <pre><code>class Storage_Container_Apc extends Storage_Container implements Storage_iContainer
  {    
      protected $_id_prefix = '';   
      protected $_file_prefix = '';   
  
      function __construct($id_prefix='', $file_prefix='', $options=array())
      {               
          $this-&gt;_id_prefix = $id_prefix; 
          $this-&gt;_file_prefix = $file_prefix; 
      } 
  
      /**
       * @see Storage_iContainer::available
       */
      public static function available()
      { 
          return extension_loaded('apc') &amp;&amp; ini_get('apc.enabled');
      } 
  }
  </code></pre>
  
  <p>And this basic testcase.</p>
  
  <pre><code>class StorageContainerApcTest extends \PHPUnit_Framework_TestCase
  {
      public function testAvailability()
      {
          $this-&gt;assertTrue(Storage_Container_Apc::available());
      }
  }
  </code></pre>
  
  <p>On systems without APC this test will obviously fail, however it's not really a failure of course because the class is module dependent and not used if it is not available on the system. So for this point what should the test actually be, so that it returns ok. Would it be something like this?</p>
  
  <pre><code>class StorageContainerApcTest extends \PHPUnit_Framework_TestCase
  {
      public function testAvailability()
      {
          if(extension_loaded('apc') &amp;&amp; ini_get('apc.enabled'))
          {
              $this-&gt;assertTrue(Storage_Container_Apc::available());
          }
          else
          {
              $this-&gt;assertFalse(Storage_Container_Apc::available());
          }
      }
  }
  </code></pre>
  
  <p>My last question involves how to test these opcode wrappers with tests. As it is impossible to run more than one opcode at any given time?</p>
  
  <p>Many thanks for any pointers.</p>