@KoRNeT46RuS

Как авторизоваться в unit test zf2?

Что дописать, чтобы во время тестирования контроллера он видел, что его, якобы тестирует, авторизованный пользователь в Unit тестировании ZF2
public function _before(\UnitTester $I)
    {
        $serviceManager = Bootstrap::getServiceManager();
        $this->controller = new TaskController();
        $this->request = new Request();
        $this->response = new Response();
        $this->routeMatch = new RouteMatch(['controller' => 'Task']);
        $this->event = new MvcEvent();
        $config = $serviceManager->get('Config');
        $routeConfig = isset($config['router']) ? $config['router'] : [];
        $router = HttpRouter::factory($routeConfig);

        $this->event->setRouter($router);
        $this->event->setRouteMatch($this->routeMatch);
        $this->event->setRequest($this->request);
        $this->event->setResponse($this->response);
        $this->controller->setEvent($this->event);
        $this->controller->setServiceLocator($serviceManager);
    }
  • Вопрос задан
  • 85 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы