public function testDumpWithTooManyRoutes()
 {
     $this->routeCollection->add('Test', new Route('/testing/{foo}'));
     for ($i = 0; $i < 32769; ++$i) {
         $this->routeCollection->add('route_' . $i, new Route('/route_' . $i));
     }
     $this->routeCollection->add('Test2', new Route('/testing2'));
     $data = $this->generatorDumper->dump(array('class' => 'ProjectLargeUrlGenerator'));
     file_put_contents($this->largeTestTmpFilepath, $data);
     include $this->largeTestTmpFilepath;
     $projectUrlGenerator = new \ProjectLargeUrlGenerator(new RequestContext('/app.php'));
     $absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
     $absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
     $relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
     $relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
     $this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
     $this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
     $this->assertEquals($relativeUrlWithParameter, '/app.php/testing/bar');
     $this->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2');
 }
Exemplo n.º 2
0
 public function testDumpWithTooManyRoutes()
 {
     if (defined('HHVM_VERSION_ID')) {
         $this->markTestSkipped('HHVM consumes too much memory on this test.');
     }
     $this->routeCollection->add('Test', new Route('/testing/{foo}'));
     for ($i = 0; $i < 32769; ++$i) {
         $this->routeCollection->add('route_' . $i, new Route('/route_' . $i));
     }
     $this->routeCollection->add('Test2', new Route('/testing2'));
     file_put_contents($this->largeTestTmpFilepath, $this->generatorDumper->dump(array('class' => 'ProjectLargeUrlGenerator')));
     $this->routeCollection = $this->generatorDumper = null;
     include $this->largeTestTmpFilepath;
     $projectUrlGenerator = new \ProjectLargeUrlGenerator(new RequestContext('/app.php'));
     $absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
     $absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
     $relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
     $relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
     $this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
     $this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
     $this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
     $this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
 }