protected function setUp()
 {
     $this->serviceManager = ServiceManagerFactory::getServiceManager();
     $this->controller = new IndexController();
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(['controller' => IndexController::class]);
     $this->event = new MvcEvent();
     $config = $this->serviceManager->get('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : [];
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }
 public function testControllerFactoryReturnsControllerInstance()
 {
     $factory = new IndexControllerFactory();
     $controllerManager = ServiceManagerFactory::getServiceManager()->get('ControllerManager');
     $this->assertInstanceOf(IndexController::class, $factory->createService($controllerManager));
 }
<?php

use ApplicationTest\Util\ServiceManagerFactory;
ini_set('error_reporting', E_ALL);
$files = [getcwd() . '/../../vendor/autoload.php', getcwd() . '/../../autoload.php'];
foreach ($files as $file) {
    if (file_exists($file)) {
        $loader = (require $file);
        break;
    }
}
if (!isset($loader)) {
    throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
}
/* @var $loader \Composer\Autoload\ClassLoader */
$loader->add('Application\\', __DIR__ . '/../src');
$loader->add('ApplicationTest\\', __DIR__);
if (file_exists(__DIR__ . '/TestConfiguration.php')) {
    $config = (require __DIR__ . '/TestConfiguration.php');
} else {
    $config = (require __DIR__ . '/TestConfiguration.php.dist');
}
ServiceManagerFactory::setConfig($config);
unset($files, $file, $loader, $config);
use ApplicationTest\Util\ServiceManagerFactory;
ini_set('error_reporting', E_ALL);
if (!defined('IS_DEV')) {
    define('IS_DEV', true);
}
if (!defined('IS_PRD')) {
    define('IS_PRD', false);
}
if (!defined('IS_STG')) {
    define('IS_STG', false);
}
$files = [__DIR__ . '/../../../vendor/autoload.php'];
foreach ($files as $file) {
    if (file_exists($file)) {
        $loader = (require $file);
        break;
    }
}
if (!isset($loader)) {
    throw new RuntimeException('vendor/autoload.php could not be found. Did you install via composer?');
}
$loader->add('ApplicationTest\\', __DIR__);
$configFiles = [__DIR__ . '/TestConfiguration.php', __DIR__ . '/TestConfiguration.php.dist'];
foreach ($configFiles as $configFile) {
    if (file_exists($configFile)) {
        $config = (require $configFile);
        break;
    }
}
ServiceManagerFactory::setApplicationConfig($config);
unset($files, $file, $loader, $configFiles, $configFile, $config);
 public function testFactoryReturnsInstance()
 {
     $factory = new IntlListenerFactory();
     $this->assertInstanceOf(IntlListener::class, $factory->createService(ServiceManagerFactory::getServiceManager()));
 }