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)); }
public function testFactoryReturnsInstance() { $factory = new IntlListenerFactory(); $this->assertInstanceOf(IntlListener::class, $factory->createService(ServiceManagerFactory::getServiceManager())); }