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 provideTestBadExposeSet * @expectedException \RuntimeException */ public function testBadExposeSet($exposeSets) { $routes = new RouteCollection(); $routes->add('literal', new Route('/literal', array(), array(), array('expose_sets' => $exposeSets))); $router = $this->getRouter($routes); $extractor = new ExposedRoutesExtractor($router, array('.*'), $this->cacheDir, array()); $extractor->getRoutes(array('set')); }