title: Factory Class not found while testing ZF2 app
body: <p>I'm new on ZF2 and I have a problem to test a Factory Class.</p>
  
  <p>This is my contollers.config.php</p>
  
  <pre><code>   &lt;?php
  
  return array(
      'invokables' =&gt; array(
          'Application\Controller\Index' =&gt; 'Application\Controller\IndexController',
          'Application\Controller\SystemStatus' =&gt; 'Application\Controller\SystemStatusController',
      ),
      'factories' =&gt; array(
          'Application\Controller\HomePage' =&gt; 'Application\Controller\Factory\HomePageControllerFactory',
      ),
  );
  </code></pre>
  
  <p>My path to the Factory Class is:</p>
  
  <p>/app/src/module/Application/src/Application/Controller/Factory/HomePageControllerFactory.php</p>
  
  <p>And the file looks like:</p>
  
  <pre><code>&lt;?php
  namespace Application\Controller\Factory;
  
  use Zend\ServiceManager\FactoryInterface;
  use Zend\ServiceManager\ServiceLocatorInterface;
  use Application\Controller\HomePageController;
  
  class HomePageControllerFactory implements FactoryInterface {
  
      /**
       * @param ServiceLocatorInterface $sm
       * @return HomePageController|mixed
       */
      public function createService(ServiceLocatorInterface $sm)
      {
          $queryParams = $sm-&gt;getServiceLocator()-&gt;get('path\path');
          $service = $sm-&gt;getServiceLocator()-&gt;get('path\path');
          return new HomePageController($queryParams, $service);
      }
  
  }
  </code></pre>
  
  <p>My path to the Test is:
  /app/tests/ApplicationTest/Integration/Controller/Factory/HomePageControllerFactoryTest.php</p>
  
  <p>and the only that I have inside is:</p>
  
  <pre><code>&lt;?php
  
  namespace ApplicationTest\Integration\Controller\Factory;
  
  use Application\Controller\Factory\HomePageControllerFactory;
  use PHPUnit_Framework_TestCase as TestCase;
  
  class HomePageControllerFactoryTest extends TestCase
  {
      /**
       * @var HomePageControllerFactory
       */
      private $underTest;
  
      public function setUp()
      {
         $this-&gt;underTest = new HomePageControllerFactory();
      }
  
  public function testCreateService()
      {
  
        /*Nothing*/
  
      }
  
  }
  </code></pre>
  
  <p>and when I run the test this is the ouput</p>
  
  <pre><code>PHP Fatal error:  Class 'Application\Controller\Factory\HomePageControllerFactory' not found in /apps/tests/ApplicationTest/Integration/Controller/Factory/HomePageControllerFactoryTest.php on line 17
  </code></pre>
  
  <p>Bootstrap.php is located /app/tests/Bootstrap.php</p>
  
  <p>content:</p>
  
  <pre><code>    &lt;?php
  
  namespace ApplicationTest;
  
  use Zend\Loader\AutoloaderFactory
      , Zend\Mvc\Service\ServiceManagerConfig
      , Zend\ServiceManager\ServiceManager;
  
  date_default_timezone_set('America/New_York');
  error_reporting(E_ALL | E_STRICT);
  chdir(dirname(__DIR__));
  
  require 'vendor/autoload.php';
  
  class Bootstrap
  {
      private static $instance;
      private $serviceManager;
  
      public static function getInstance()
      {
          if (!isset(static::$instance)) {
              $class = get_class();
              static::$instance = new $class;
          }
  
          return static::$instance;
      }
  
      public static function init()
      {
          AutoloaderFactory::factory();
          static::getInstance();
      }
  
      public function getServiceManager()
      {
          if (!isset($this-&gt;serviceManager)) {
              $this-&gt;serviceManager = new ServiceManager(new ServiceManagerConfig());
          }
          return $this-&gt;serviceManager;
      }
  
      public function setServiceManager(ServiceManager $sm)
      {
          $this-&gt;serviceManager = $sm;
      }
  
      public function getConfig()
      {
          if (is_readable(__DIR__ . '/TestConfig.php')) {
              return require __DIR__ . '/TestConfig.php';
          } else {
              return require './src/config/application.config.php';
          }
      }
  
      private function __construct()
      {
      }
  }
  
  Bootstrap::init();
  </code></pre>
  
  <p>I'm stuck on this, I don't know why I can not instance an object of HomePageControllerFactory</p>