@@ -34,14 +34,21 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase
34
34
*/
35
35
private $ testTmpFilepath ;
36
36
37
+ /**
38
+ * @var string
39
+ */
40
+ private $ largeTestTmpFilepath ;
41
+
37
42
protected function setUp ()
38
43
{
39
44
parent ::setUp ();
40
45
41
46
$ this ->routeCollection = new RouteCollection ();
42
47
$ this ->generatorDumper = new PhpGeneratorDumper ($ this ->routeCollection );
43
48
$ this ->testTmpFilepath = sys_get_temp_dir ().DIRECTORY_SEPARATOR .'php_generator. ' .$ this ->getName ().'.php ' ;
49
+ $ this ->largeTestTmpFilepath = sys_get_temp_dir ().DIRECTORY_SEPARATOR .'php_generator. ' .$ this ->getName ().'.large.php ' ;
44
50
@unlink ($ this ->testTmpFilepath );
51
+ @unlink ($ this ->largeTestTmpFilepath );
45
52
}
46
53
47
54
protected function tearDown ()
@@ -76,6 +83,33 @@ public function testDumpWithRoutes()
76
83
$ this ->assertEquals ($ relativeUrlWithoutParameter , '/app.php/testing2 ' );
77
84
}
78
85
86
+ public function testDumpWithTooManyRoutes ()
87
+ {
88
+ $ this ->routeCollection ->add ('Test ' , new Route ('/testing/{foo} ' ));
89
+ for ( $ i = 0 ; $ i < 32769 ; ++$ i ) {
90
+ $ this ->routeCollection ->add ('route_ ' .$ i , new Route ('/route_ ' .$ i ));
91
+ }
92
+ $ this ->routeCollection ->add ('Test2 ' , new Route ('/testing2 ' ));
93
+
94
+ $ data = $ this ->generatorDumper ->dump (array (
95
+ 'class ' => 'ProjectLargeUrlGenerator ' ,
96
+ ));
97
+ file_put_contents ($ this ->largeTestTmpFilepath , $ data );
98
+ include $ this ->largeTestTmpFilepath ;
99
+
100
+ $ projectUrlGenerator = new \ProjectLargeUrlGenerator (new RequestContext ('/app.php ' ));
101
+
102
+ $ absoluteUrlWithParameter = $ projectUrlGenerator ->generate ('Test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface::ABSOLUTE_URL );
103
+ $ absoluteUrlWithoutParameter = $ projectUrlGenerator ->generate ('Test2 ' , array (), UrlGeneratorInterface::ABSOLUTE_URL );
104
+ $ relativeUrlWithParameter = $ projectUrlGenerator ->generate ('Test ' , array ('foo ' => 'bar ' ), UrlGeneratorInterface::ABSOLUTE_PATH );
105
+ $ relativeUrlWithoutParameter = $ projectUrlGenerator ->generate ('Test2 ' , array (), UrlGeneratorInterface::ABSOLUTE_PATH );
106
+
107
+ $ this ->assertEquals ($ absoluteUrlWithParameter , 'http://localhost/app.php/testing/bar ' );
108
+ $ this ->assertEquals ($ absoluteUrlWithoutParameter , 'http://localhost/app.php/testing2 ' );
109
+ $ this ->assertEquals ($ relativeUrlWithParameter , '/app.php/testing/bar ' );
110
+ $ this ->assertEquals ($ relativeUrlWithoutParameter , '/app.php/testing2 ' );
111
+ }
112
+
79
113
/**
80
114
* @expectedException \InvalidArgumentException
81
115
*/
0 commit comments