/**
  * Check the admin index page
  */
 public function testIndex()
 {
     $url = self::$router->generate('admin_index');
     $crawler = self::$client->request('GET', $url);
     $this->assertEquals(self::$client->getResponse()->getStatusCode(), Response::HTTP_OK);
     $this->assertTrue($crawler->filter('html:contains("welcome")')->count() > 0);
 }
 public function testContact()
 {
     $url = self::$router->generate('page_contact');
     $crawler = self::$client->request('GET', $url);
     $this->assertEquals(Response::HTTP_OK, self::$client->getResponse()->getStatusCode());
     $this->assertTrue($crawler->filter('html:contains("099 09 08 557")')->count() > 0);
 }
 public function testShow()
 {
     $url = self::$router->generate('news_index');
     $crawler = self::$client->request('GET', $url);
     $slug = $crawler->filter('[data-article-slug]')->first()->attr('data-article-slug');
     $url = self::$router->generate('site_article_show', ['slug' => $slug]);
     $crawler = self::$client->request('GET', $url);
     $this->assertEquals(Response::HTTP_OK, self::$client->getResponse()->getStatusCode());
     $this->assertTrue($crawler->filter('[data-article-slug]')->count() > 0);
 }
 /**
  * Test user can submit the comment form
  *
  * @depends testShow
  * @param sting slug
  */
 public function testSubmitComment($slug)
 {
     $url = self::$router->generate('site_service_show', ['slug' => $slug]);
     $crawler = self::$client->request('GET', $url);
     $this->assertEquals(Response::HTTP_OK, self::$client->getResponse()->getStatusCode());
     $form = $crawler->filter('form[name=koopa_app_comment]');
     $this->assertTrue($form->count() > 0);
     $form = $form->form();
     $form['koopa_app_comment[content]'] = 'I like this service';
     self::$client->submit($form);
     $crawler = self::$client->followRedirect();
     $this->assertRegExp('/I like this service/', self::$client->getResponse()->getContent());
 }
 /**
  * @param $id
  * @depends testEdit
  */
 public function testDelete($id)
 {
     $url = self::$router->generate('service_edit', ['id' => $id]);
     $crawler = self::$client->request('GET', $url);
     $form = $crawler->filter('form[id=form_delete]')->form();
     self::$client->submit($form);
     self::$client->followRedirect();
     $this->assertEquals(Response::HTTP_OK, self::$client->getResponse()->getStatusCode());
     $this->assertNotRegExp('/BarTEST/', self::$client->getResponse()->getContent());
 }
 /**
  * kernel.controller listener method
  * 
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $this->request = $event->getRequest();
     $this->matchedRoute = $this->request->get('_route');
     if ($this->request->isXmlHttpRequest()) {
         // this is an Ajax request we do not need to have breadcrumbs here
         return;
     }
     if (!$this->validate()) {
         return;
     }
     // find a matching breadcrumb node by route
     $node = $this->breadcrumbTreeService->getNodeByRoute($this->matchedRoute);
     if ($node) {
         $routeObj = $this->router->getRouteCollection()->get($this->matchedRoute);
         $compiledRoute = $routeObj->compile();
         $commonParams = $this->request->get('_route_params');
         $ancestorItems = array();
         $ancestors = $this->breadcrumbTreeService->getPathOfNode($node, false);
         foreach ($ancestors as $breadcrumbObj) {
             $breadcrumbItem = array('name' => $breadcrumbObj->getLabel(), 'href' => null, 'params' => array());
             // compile the route for each node
             if ($routeObj = $this->router->getRouteCollection()->get($breadcrumbObj->getRoute())) {
                 $compiledRoute = $routeObj->compile();
                 // use key intersect to get the common request parameters in this current Request context and this node
                 $intersectedParams = \array_intersect_key($commonParams, \array_flip($compiledRoute->getVariables()));
                 $breadcrumbItem['params'] = $intersectedParams;
                 try {
                     $breadcrumbItem['href'] = $this->router->generate($breadcrumbObj->getRoute(), $intersectedParams);
                 } catch (\Exception $e) {
                     // do nothing here since we will only display the breadcrumb label if there is no generated link
                 }
             }
             $ancestorItems[] = $breadcrumbItem;
         }
         // render the template for the breadcrumbs
         $breadcrumbs = $this->twig->render($this->templateName, array('currentNode' => $node, 'ancestorItems' => $ancestorItems));
     } else {
         $breadcrumbs = null;
     }
     $this->twig->addGlobal('breadcrumbs', $breadcrumbs);
 }
 /**
  * Gets the 'router' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Symfony\Bundle\FrameworkBundle\Routing\Router A Symfony\Bundle\FrameworkBundle\Routing\Router instance.
  */
 protected function getRouterService()
 {
     $this->services['router'] = $instance = new \Symfony\Bundle\FrameworkBundle\Routing\Router($this, $this->targetDirs[2] . '/config/routing_dev.yml', array('cache_dir' => __DIR__, 'debug' => true, 'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 'generator_base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 'generator_dumper_class' => 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper', 'generator_cache_class' => 'appDevUrlGenerator', 'matcher_class' => 'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher', 'matcher_base_class' => 'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher', 'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper', 'matcher_cache_class' => 'appDevUrlMatcher', 'strict_requirements' => true), $this->get('router.request_context', ContainerInterface::NULL_ON_INVALID_REFERENCE), $this->get('monolog.logger.router', ContainerInterface::NULL_ON_INVALID_REFERENCE));
     $instance->setConfigCacheFactory($this->get('config_cache_factory'));
     return $instance;
 }