public function testGetRoutesWithPatterns() { $router = $this->getRouter(array('hello_you' => new Route('/foo', array('_controller' => '')), 'hello_123' => new Route('/foo', array('_controller' => '')), 'hello_world' => new Route('/foo', array('_controller' => '')))); $extractor = new ExposedRoutesExtractor($router, array('hello_.*')); $this->assertEquals(3, count($extractor->getRoutes()), '3 routes match the pattern: "hello_.*"'); $extractor = new ExposedRoutesExtractor($router, array('hello_[0-9]{3}')); $this->assertEquals(1, count($extractor->getRoutes()), '1 routes match the pattern: "hello_[0-9]{3}"'); $extractor = new ExposedRoutesExtractor($router, array('hello_[0-9]{4}')); $this->assertEquals(0, count($extractor->getRoutes()), '1 routes match the pattern: "hello_[0-9]{4}"'); $extractor = new ExposedRoutesExtractor($router, array('hello_.+o.+')); $this->assertEquals(2, count($extractor->getRoutes()), '2 routes match the pattern: "hello_.+o.+"'); $extractor = new ExposedRoutesExtractor($router, array('hello_.+o.+', 'hello_123')); $this->assertEquals(3, count($extractor->getRoutes()), '3 routes match patterns: "hello_.+o.+" and "hello_123"'); $extractor = new ExposedRoutesExtractor($router, array('hello_.+o.+', 'hello_$')); $this->assertEquals(2, count($extractor->getRoutes()), '2 routes match patterns: "hello_.+o.+" and "hello_"'); $extractor = new ExposedRoutesExtractor($router, array()); $this->assertEquals(0, count($extractor->getRoutes()), 'No patterns so no matched routes'); }
/** * @dataProvider provideTestGetHostOverHttps */ public function testGetHostOverHttps($host, $httpsPort, $expected) { $requestContext = new RequestContext('/app_dev.php', 'GET', $host, 'https', 80, $httpsPort); $router = $this->getMock('Symfony\\Component\\Routing\\Router', array(), array(), '', false); $router->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($requestContext)); $extractor = new ExposedRoutesExtractor($router, array(), $this->cacheDir, array()); $this->assertEquals($expected, $extractor->getHost()); }