K
K
KoRNeT46RuS2016-11-25 11:25:40
Zend Framework
KoRNeT46RuS, 2016-11-25 11:25:40

How to login to unit test zf2?

What to add so that during the testing of the controller he sees that he is allegedly being tested by an authorized user in Unit testing 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);
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question