Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit608c8d2

Browse files
Tobionfabpot
authored andcommitted
[Routing] use constants in tests
1 parentb06a938 commit608c8d2

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

‎src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespaceSymfony\Component\Routing\Tests\Generator\Dumper;
1313

14+
useSymfony\Component\Routing\Generator\UrlGeneratorInterface;
1415
useSymfony\Component\Routing\RouteCollection;
1516
useSymfony\Component\Routing\Route;
1617
useSymfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
@@ -64,10 +65,10 @@ public function testDumpWithRoutes()
6465

6566
$projectUrlGenerator =new \ProjectUrlGenerator(newRequestContext('/app.php'));
6667

67-
$absoluteUrlWithParameter =$projectUrlGenerator->generate('Test',array('foo' =>'bar'),true);
68-
$absoluteUrlWithoutParameter =$projectUrlGenerator->generate('Test2',array(),true);
69-
$relativeUrlWithParameter =$projectUrlGenerator->generate('Test',array('foo' =>'bar'),false);
70-
$relativeUrlWithoutParameter =$projectUrlGenerator->generate('Test2',array(),false);
68+
$absoluteUrlWithParameter =$projectUrlGenerator->generate('Test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_URL);
69+
$absoluteUrlWithoutParameter =$projectUrlGenerator->generate('Test2',array(),UrlGeneratorInterface::ABSOLUTE_URL);
70+
$relativeUrlWithParameter =$projectUrlGenerator->generate('Test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_PATH);
71+
$relativeUrlWithoutParameter =$projectUrlGenerator->generate('Test2',array(),UrlGeneratorInterface::ABSOLUTE_PATH);
7172

7273
$this->assertEquals($absoluteUrlWithParameter,'http://localhost/app.php/testing/bar');
7374
$this->assertEquals($absoluteUrlWithoutParameter,'http://localhost/app.php/testing2');

‎src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,55 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
2222
publicfunctiontestAbsoluteUrlWithPort80()
2323
{
2424
$routes =$this->getRoutes('test',newRoute('/testing'));
25-
$url =$this->getGenerator($routes)->generate('test',array(),true);
25+
$url =$this->getGenerator($routes)->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_URL);
2626

2727
$this->assertEquals('http://localhost/app.php/testing',$url);
2828
}
2929

3030
publicfunctiontestAbsoluteSecureUrlWithPort443()
3131
{
3232
$routes =$this->getRoutes('test',newRoute('/testing'));
33-
$url =$this->getGenerator($routes,array('scheme' =>'https'))->generate('test',array(),true);
33+
$url =$this->getGenerator($routes,array('scheme' =>'https'))->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_URL);
3434

3535
$this->assertEquals('https://localhost/app.php/testing',$url);
3636
}
3737

3838
publicfunctiontestAbsoluteUrlWithNonStandardPort()
3939
{
4040
$routes =$this->getRoutes('test',newRoute('/testing'));
41-
$url =$this->getGenerator($routes,array('httpPort' =>8080))->generate('test',array(),true);
41+
$url =$this->getGenerator($routes,array('httpPort' =>8080))->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_URL);
4242

4343
$this->assertEquals('http://localhost:8080/app.php/testing',$url);
4444
}
4545

4646
publicfunctiontestAbsoluteSecureUrlWithNonStandardPort()
4747
{
4848
$routes =$this->getRoutes('test',newRoute('/testing'));
49-
$url =$this->getGenerator($routes,array('httpsPort' =>8080,'scheme' =>'https'))->generate('test',array(),true);
49+
$url =$this->getGenerator($routes,array('httpsPort' =>8080,'scheme' =>'https'))->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_URL);
5050

5151
$this->assertEquals('https://localhost:8080/app.php/testing',$url);
5252
}
5353

5454
publicfunctiontestRelativeUrlWithoutParameters()
5555
{
5656
$routes =$this->getRoutes('test',newRoute('/testing'));
57-
$url =$this->getGenerator($routes)->generate('test',array(),false);
57+
$url =$this->getGenerator($routes)->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_PATH);
5858

5959
$this->assertEquals('/app.php/testing',$url);
6060
}
6161

6262
publicfunctiontestRelativeUrlWithParameter()
6363
{
6464
$routes =$this->getRoutes('test',newRoute('/testing/{foo}'));
65-
$url =$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),false);
65+
$url =$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_PATH);
6666

6767
$this->assertEquals('/app.php/testing/bar',$url);
6868
}
6969

7070
publicfunctiontestRelativeUrlWithNullParameter()
7171
{
7272
$routes =$this->getRoutes('test',newRoute('/testing.{format}',array('format' =>null)));
73-
$url =$this->getGenerator($routes)->generate('test',array(),false);
73+
$url =$this->getGenerator($routes)->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_PATH);
7474

7575
$this->assertEquals('/app.php/testing',$url);
7676
}
@@ -83,13 +83,13 @@ public function testRelativeUrlWithNullParameterButNotOptional()
8383
$routes =$this->getRoutes('test',newRoute('/testing/{foo}/bar',array('foo' =>null)));
8484
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
8585
// Generating path "/testing//bar" would be wrong as matching this route would fail.
86-
$this->getGenerator($routes)->generate('test',array(),false);
86+
$this->getGenerator($routes)->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_PATH);
8787
}
8888

8989
publicfunctiontestRelativeUrlWithOptionalZeroParameter()
9090
{
9191
$routes =$this->getRoutes('test',newRoute('/testing/{page}'));
92-
$url =$this->getGenerator($routes)->generate('test',array('page' =>0),false);
92+
$url =$this->getGenerator($routes)->generate('test',array('page' =>0),UrlGeneratorInterface::ABSOLUTE_PATH);
9393

9494
$this->assertEquals('/app.php/testing/0',$url);
9595
}
@@ -104,23 +104,23 @@ public function testNotPassedOptionalParameterInBetween()
104104
publicfunctiontestRelativeUrlWithExtraParameters()
105105
{
106106
$routes =$this->getRoutes('test',newRoute('/testing'));
107-
$url =$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),false);
107+
$url =$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_PATH);
108108

109109
$this->assertEquals('/app.php/testing?foo=bar',$url);
110110
}
111111

112112
publicfunctiontestAbsoluteUrlWithExtraParameters()
113113
{
114114
$routes =$this->getRoutes('test',newRoute('/testing'));
115-
$url =$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),true);
115+
$url =$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_URL);
116116

117117
$this->assertEquals('http://localhost/app.php/testing?foo=bar',$url);
118118
}
119119

120120
publicfunctiontestUrlWithNullExtraParameters()
121121
{
122122
$routes =$this->getRoutes('test',newRoute('/testing'));
123-
$url =$this->getGenerator($routes)->generate('test',array('foo' =>null),true);
123+
$url =$this->getGenerator($routes)->generate('test',array('foo' =>null),UrlGeneratorInterface::ABSOLUTE_URL);
124124

125125
$this->assertEquals('http://localhost/app.php/testing',$url);
126126
}
@@ -167,7 +167,7 @@ public function testGlobalParameterHasHigherPriorityThanDefault()
167167
publicfunctiontestGenerateWithoutRoutes()
168168
{
169169
$routes =$this->getRoutes('foo',newRoute('/testing/{foo}'));
170-
$this->getGenerator($routes)->generate('test',array(),true);
170+
$this->getGenerator($routes)->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_URL);
171171
}
172172

173173
/**
@@ -176,7 +176,7 @@ public function testGenerateWithoutRoutes()
176176
publicfunctiontestGenerateForRouteWithoutMandatoryParameter()
177177
{
178178
$routes =$this->getRoutes('test',newRoute('/testing/{foo}'));
179-
$this->getGenerator($routes)->generate('test',array(),true);
179+
$this->getGenerator($routes)->generate('test',array(),UrlGeneratorInterface::ABSOLUTE_URL);
180180
}
181181

182182
/**
@@ -185,7 +185,7 @@ public function testGenerateForRouteWithoutMandatoryParameter()
185185
publicfunctiontestGenerateForRouteWithInvalidOptionalParameter()
186186
{
187187
$routes =$this->getRoutes('test',newRoute('/testing/{foo}',array('foo' =>'1'),array('foo' =>'d+')));
188-
$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),true);
188+
$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_URL);
189189
}
190190

191191
/**
@@ -194,15 +194,15 @@ public function testGenerateForRouteWithInvalidOptionalParameter()
194194
publicfunctiontestGenerateForRouteWithInvalidParameter()
195195
{
196196
$routes =$this->getRoutes('test',newRoute('/testing/{foo}',array(),array('foo' =>'1|2')));
197-
$this->getGenerator($routes)->generate('test',array('foo' =>'0'),true);
197+
$this->getGenerator($routes)->generate('test',array('foo' =>'0'),UrlGeneratorInterface::ABSOLUTE_URL);
198198
}
199199

200200
publicfunctiontestGenerateForRouteWithInvalidOptionalParameterNonStrict()
201201
{
202202
$routes =$this->getRoutes('test',newRoute('/testing/{foo}',array('foo' =>'1'),array('foo' =>'d+')));
203203
$generator =$this->getGenerator($routes);
204204
$generator->setStrictRequirements(false);
205-
$this->assertNull($generator->generate('test',array('foo' =>'bar'),true));
205+
$this->assertNull($generator->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_URL));
206206
}
207207

208208
publicfunctiontestGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
@@ -213,7 +213,7 @@ public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLog
213213
->method('error');
214214
$generator =$this->getGenerator($routes,array(),$logger);
215215
$generator->setStrictRequirements(false);
216-
$this->assertNull($generator->generate('test',array('foo' =>'bar'),true));
216+
$this->assertNull($generator->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_URL));
217217
}
218218

219219
publicfunctiontestGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()
@@ -230,7 +230,7 @@ public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsC
230230
publicfunctiontestGenerateForRouteWithInvalidMandatoryParameter()
231231
{
232232
$routes =$this->getRoutes('test',newRoute('/testing/{foo}',array(),array('foo' =>'d+')));
233-
$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),true);
233+
$this->getGenerator($routes)->generate('test',array('foo' =>'bar'),UrlGeneratorInterface::ABSOLUTE_URL);
234234
}
235235

236236
/**
@@ -405,7 +405,7 @@ public function testWithHostSameAsContextAndAbsolute()
405405
{
406406
$routes =$this->getRoutes('test',newRoute('/{name}',array(),array(),array(),'{locale}.example.com'));
407407

408-
$this->assertEquals('http://fr.example.com/app.php/Fabien',$this->getGenerator($routes,array('host' =>'fr.example.com'))->generate('test',array('name' =>'Fabien','locale' =>'fr'),true));
408+
$this->assertEquals('http://fr.example.com/app.php/Fabien',$this->getGenerator($routes,array('host' =>'fr.example.com'))->generate('test',array('name' =>'Fabien','locale' =>'fr'),UrlGeneratorInterface::ABSOLUTE_URL));
409409
}
410410

411411
/**
@@ -414,7 +414,7 @@ public function testWithHostSameAsContextAndAbsolute()
414414
publicfunctiontestUrlWithInvalidParameterInHost()
415415
{
416416
$routes =$this->getRoutes('test',newRoute('/',array(),array('foo' =>'bar'),array(),'{foo}.example.com'));
417-
$this->getGenerator($routes)->generate('test',array('foo' =>'baz'),false);
417+
$this->getGenerator($routes)->generate('test',array('foo' =>'baz'),UrlGeneratorInterface::ABSOLUTE_PATH);
418418
}
419419

420420
/**
@@ -423,7 +423,7 @@ public function testUrlWithInvalidParameterInHost()
423423
publicfunctiontestUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
424424
{
425425
$routes =$this->getRoutes('test',newRoute('/',array('foo' =>'bar'),array('foo' =>'bar'),array(),'{foo}.example.com'));
426-
$this->getGenerator($routes)->generate('test',array('foo' =>'baz'),false);
426+
$this->getGenerator($routes)->generate('test',array('foo' =>'baz'),UrlGeneratorInterface::ABSOLUTE_PATH);
427427
}
428428

429429
/**
@@ -432,15 +432,15 @@ public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
432432
publicfunctiontestUrlWithInvalidParameterEqualsDefaultValueInHost()
433433
{
434434
$routes =$this->getRoutes('test',newRoute('/',array('foo' =>'baz'),array('foo' =>'bar'),array(),'{foo}.example.com'));
435-
$this->getGenerator($routes)->generate('test',array('foo' =>'baz'),false);
435+
$this->getGenerator($routes)->generate('test',array('foo' =>'baz'),UrlGeneratorInterface::ABSOLUTE_PATH);
436436
}
437437

438438
publicfunctiontestUrlWithInvalidParameterInHostInNonStrictMode()
439439
{
440440
$routes =$this->getRoutes('test',newRoute('/',array(),array('foo' =>'bar'),array(),'{foo}.example.com'));
441441
$generator =$this->getGenerator($routes);
442442
$generator->setStrictRequirements(false);
443-
$this->assertNull($generator->generate('test',array('foo' =>'baz'),false));
443+
$this->assertNull($generator->generate('test',array('foo' =>'baz'),UrlGeneratorInterface::ABSOLUTE_PATH));
444444
}
445445

446446
publicfunctiontestHostIsCaseInsensitive()

‎src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
useSymfony\Component\HttpFoundation\Request;
1515
useSymfony\Component\Routing\Exception\MethodNotAllowedException;
1616
useSymfony\Component\Routing\Exception\ResourceNotFoundException;
17+
useSymfony\Component\Routing\Generator\UrlGeneratorInterface;
1718
useSymfony\Component\Security\Core\SecurityContextInterface;
1819
useSymfony\Component\Security\Http\HttpUtils;
1920

@@ -43,7 +44,7 @@ public function testCreateRedirectResponseWithRouteName()
4344
$urlGenerator
4445
->expects($this->any())
4546
->method('generate')
46-
->with('foobar',array(),true)
47+
->with('foobar',array(),UrlGeneratorInterface::ABSOLUTE_URL)
4748
->will($this->returnValue('http://localhost/foo/bar'))
4849
;
4950
$urlGenerator

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp