Skip to content

Commit 78866be

Browse files
Merge branch '6.4' into 7.0
* 6.4: [Cache] fix the previous fix [Cache] Fix expiration time for CouchbaseCollection [FrameworkBundle] Update docblock AbstractController [HttpFoundation][FrameworkBundle] Fix default locale is ignored when set_locale_from_accept_language is used add missing translations [Validator] updated Lithuanian translation [Validator] fix some non-sense Lithuanian translations [Validator] updated Slovenian translation [Validator] updated Finnish translation [RateLimit] Test and fix peeking behavior on rate limit policies [Validator] Add `Charset` french translation [Tests] Streamline CompiledUrlGenerator tests [Serializer] Skip uninitialized properties with deep_object_to_populate fix Constraints\Email::ERROR_NAMES
2 parents fc55062 + 98eab13 commit 78866be

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php

+33-22
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ public function testDumpWithSimpleLocalizedRoutes()
104104

105105
public function testDumpWithRouteNotFoundLocalizedRoutes()
106106
{
107-
$this->expectException(RouteNotFoundException::class);
108-
$this->expectExceptionMessage('Unable to generate a URL for the named route "test" as such route does not exist.');
109107
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'en'));
110108

111109
$code = $this->generatorDumper->dump();
112110
file_put_contents($this->testTmpFilepath, $code);
113111

114112
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'), null, 'pl_PL');
113+
114+
$this->expectException(RouteNotFoundException::class);
115+
$this->expectExceptionMessage('Unable to generate a URL for the named route "test" as such route does not exist.');
116+
115117
$projectUrlGenerator->generate('test');
116118
}
117119

@@ -163,22 +165,25 @@ public function testDumpWithTooManyRoutes()
163165

164166
public function testDumpWithoutRoutes()
165167
{
166-
$this->expectException(\InvalidArgumentException::class);
167168
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
168169

169170
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'));
170171

172+
$this->expectException(\InvalidArgumentException::class);
173+
171174
$projectUrlGenerator->generate('Test', []);
172175
}
173176

174177
public function testGenerateNonExistingRoute()
175178
{
176-
$this->expectException(RouteNotFoundException::class);
177179
$this->routeCollection->add('Test', new Route('/test'));
178180

179181
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
180182

181183
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
184+
185+
$this->expectException(RouteNotFoundException::class);
186+
182187
$projectUrlGenerator->generate('NonExisting', []);
183188
}
184189

@@ -267,66 +272,72 @@ public function testAliases()
267272

268273
public function testTargetAliasNotExisting()
269274
{
270-
$this->expectException(RouteNotFoundException::class);
271-
272-
$this->routeCollection->addAlias('a', 'not-existing');
275+
$this->routeCollection->add('not-existing', new Route('/not-existing'));
276+
$this->routeCollection->addAlias('alias', 'not-existing');
273277

274278
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
275279

276-
$compiledUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
280+
$compiledRoutes = require $this->testTmpFilepath;
281+
unset($compiledRoutes['alias']);
277282

283+
$this->expectException(RouteNotFoundException::class);
284+
285+
$compiledUrlGenerator = new CompiledUrlGenerator($compiledRoutes, new RequestContext());
278286
$compiledUrlGenerator->generate('a');
279287
}
280288

281289
public function testTargetAliasWithNamePrefixNotExisting()
282290
{
283-
$this->expectException(RouteNotFoundException::class);
284-
285291
$subCollection = new RouteCollection();
286-
$subCollection->addAlias('a', 'not-existing');
292+
$subCollection->add('not-existing', new Route('/not-existing'));
293+
$subCollection->addAlias('alias', 'not-existing');
287294
$subCollection->addNamePrefix('sub_');
288295

289296
$this->routeCollection->addCollection($subCollection);
290297

291298
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
292299

293-
$compiledUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
300+
$compiledRoutes = require $this->testTmpFilepath;
301+
unset($compiledRoutes['sub_alias']);
294302

295-
$compiledUrlGenerator->generate('sub_a');
303+
$this->expectException(RouteNotFoundException::class);
304+
305+
$compiledUrlGenerator = new CompiledUrlGenerator($compiledRoutes, new RequestContext());
306+
$compiledUrlGenerator->generate('sub_alias');
296307
}
297308

298309
public function testCircularReferenceShouldThrowAnException()
299310
{
300-
$this->expectException(RouteCircularReferenceException::class);
301-
$this->expectExceptionMessage('Circular reference detected for route "b", path: "b -> a -> b".');
302-
303311
$this->routeCollection->addAlias('a', 'b');
304312
$this->routeCollection->addAlias('b', 'a');
305313

314+
$this->expectException(RouteCircularReferenceException::class);
315+
$this->expectExceptionMessage('Circular reference detected for route "b", path: "b -> a -> b".');
316+
306317
$this->generatorDumper->dump();
307318
}
308319

309320
public function testDeepCircularReferenceShouldThrowAnException()
310321
{
311-
$this->expectException(RouteCircularReferenceException::class);
312-
$this->expectExceptionMessage('Circular reference detected for route "b", path: "b -> c -> b".');
313-
314322
$this->routeCollection->addAlias('a', 'b');
315323
$this->routeCollection->addAlias('b', 'c');
316324
$this->routeCollection->addAlias('c', 'b');
317325

326+
$this->expectException(RouteCircularReferenceException::class);
327+
$this->expectExceptionMessage('Circular reference detected for route "b", path: "b -> c -> b".');
328+
318329
$this->generatorDumper->dump();
319330
}
320331

321332
public function testIndirectCircularReferenceShouldThrowAnException()
322333
{
323-
$this->expectException(RouteCircularReferenceException::class);
324-
$this->expectExceptionMessage('Circular reference detected for route "b", path: "b -> c -> a -> b".');
325-
326334
$this->routeCollection->addAlias('a', 'b');
327335
$this->routeCollection->addAlias('b', 'c');
328336
$this->routeCollection->addAlias('c', 'a');
329337

338+
$this->expectException(RouteCircularReferenceException::class);
339+
$this->expectExceptionMessage('Circular reference detected for route "b", path: "b -> c -> a -> b".');
340+
330341
$this->generatorDumper->dump();
331342
}
332343

0 commit comments

Comments
 (0)