public function getFixturesByAnnotation($test) { $annotationReader = new AnnotationReader(); $className = get_class($test->getTestClass()); $methodName = $test->getName(); $reflectionObject = new ReflectionObject(new $className()); $classAnnotations = $annotationReader->getClassAnnotations($reflectionObject); $methodAnnotations = $annotationReader->getMethodAnnotations($reflectionObject->getMethod($methodName)); $testAnnotations = array_merge($classAnnotations, $methodAnnotations); $fixtures = null; foreach ($testAnnotations as $annotation) { $arr = explode(":", $annotation->value, 2); $path = $this->kernel->locateResource('@' . $arr[0]); $fixtures[] = $path . 'DataFixtures/ORM/' . $arr[1]; } codecept_debug("Fixtures to load:"); codecept_debug($fixtures); return $fixtures; }
/** * Event handler that renders not found page * in case of a NotFoundHttpException * * @param GetResponseForExceptionEvent $event * * @access public * @return void * @author Riad Hellal <*****@*****.**> */ public function onKernelException(GetResponseForExceptionEvent $event) { $this->request = $event->getRequest($event); // provide the better way to display a enhanced error page only in prod environment, if you want if (in_array($this->kernel->getEnvironment(), array('test', 'prod'))) { // exception object $exception = $event->getException(); // new Response object $response = new Response(); //$requestDuplicate = $this->request->duplicate(null, null, ['_controller' => 'MyAppSiteBundle:Default:exception']); //$response = $this->kernel->handle($requestDuplicate, HttpKernelInterface::SUB_REQUEST); if ($this->container->hasParameter('sfynx.auth.theme.layout.error.html') && $this->container->getParameter('sfynx.auth.theme.layout.error.html') != "") { $path_error_file = realpath($this->kernel->locateResource($this->container->getParameter('sfynx.auth.theme.layout.error.html'))); $response->setContent(file_get_contents($path_error_file)); } else { if ($this->container->hasParameter('sfynx.auth.theme.layout.error.route_name') && $this->container->getParameter('sfynx.auth.theme.layout.error.route_name') != "") { $route_name = $this->container->getParameter('sfynx.auth.theme.layout.error.route_name'); } else { $route_name = 'error_404'; } $url = $this->container->get('sfynx.tool.route.factory')->getRoute($route_name, array('locale' => $this->locale)); $content = PiFileManager::getCurl('/' . $url, null, null, $this->request->getUriForPath('')); $response->setContent($content); } // HttpExceptionInterface is a special type of exception // that holds status code and header details if (method_exists($exception, "getStatusCode")) { $response->setStatusCode($exception->getStatusCode()); } else { $response->setStatusCode('404'); } if (method_exists($response, "getHeaders")) { $response->headers->replace($exception->getHeaders()); } // set the new $response object to the $event $event->setResponse($response); } }