Merge branch '2.7' into 2.8
* 2.7: [Routing] use constants in tests [Process] tweaked README [Validator] Allow an empty path in a URL with only a fragment or a query [HttpFoundation] Fix some typo in the Request doc fixed CS Added separated handling of root paths
This commit is contained in:
commit
945630a8fa
@ -345,8 +345,13 @@ class Filesystem
|
|||||||
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
||||||
$depth = count($startPathArr) - $index;
|
$depth = count($startPathArr) - $index;
|
||||||
|
|
||||||
// Repeated "../" for each level need to reach the common path
|
// When we need to traverse from the start, and we are starting from a root path, don't add '../'
|
||||||
$traverser = str_repeat('../', $depth);
|
if ('/' === $startPath[0] && 0 === $index && 1 === $depth) {
|
||||||
|
$traverser = '';
|
||||||
|
} else {
|
||||||
|
// Repeated "../" for each level need to reach the common path
|
||||||
|
$traverser = str_repeat('../', $depth);
|
||||||
|
}
|
||||||
|
|
||||||
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
|
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
|
||||||
|
|
||||||
|
@ -790,6 +790,8 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
array('/a/aab/bb', '/a/aa/', '../aab/bb/'),
|
array('/a/aab/bb', '/a/aa/', '../aab/bb/'),
|
||||||
array('/a/aab/bb/', '/a/aa', '../aab/bb/'),
|
array('/a/aab/bb/', '/a/aa', '../aab/bb/'),
|
||||||
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
|
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
|
||||||
|
array('/a/aab/bb/', '/', 'a/aab/bb/'),
|
||||||
|
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
|
@ -1171,7 +1171,7 @@ class Request
|
|||||||
/**
|
/**
|
||||||
* Checks whether the request is secure or not.
|
* Checks whether the request is secure or not.
|
||||||
*
|
*
|
||||||
* This method can read the client port from the "X-Forwarded-Proto" header
|
* This method can read the client protocol from the "X-Forwarded-Proto" header
|
||||||
* when trusted proxies were set via "setTrustedProxies()".
|
* when trusted proxies were set via "setTrustedProxies()".
|
||||||
*
|
*
|
||||||
* The "X-Forwarded-Proto" header must contain the protocol: "https" or "http".
|
* The "X-Forwarded-Proto" header must contain the protocol: "https" or "http".
|
||||||
@ -1196,7 +1196,7 @@ class Request
|
|||||||
/**
|
/**
|
||||||
* Returns the host name.
|
* Returns the host name.
|
||||||
*
|
*
|
||||||
* This method can read the client port from the "X-Forwarded-Host" header
|
* This method can read the client host name from the "X-Forwarded-Host" header
|
||||||
* when trusted proxies were set via "setTrustedProxies()".
|
* when trusted proxies were set via "setTrustedProxies()".
|
||||||
*
|
*
|
||||||
* The "X-Forwarded-Host" header must contain the client host name.
|
* The "X-Forwarded-Host" header must contain the client host name.
|
||||||
|
@ -7,12 +7,13 @@ In this example, we run a simple directory listing and get the result back:
|
|||||||
|
|
||||||
```php
|
```php
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||||
|
|
||||||
$process = new Process('ls -lsa');
|
$process = new Process('ls -lsa');
|
||||||
$process->setTimeout(3600);
|
$process->setTimeout(3600);
|
||||||
$process->run();
|
$process->run();
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
throw new RuntimeException($process->getErrorOutput());
|
throw new ProcessFailedException($process);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $process->getOutput();
|
print $process->getOutput();
|
||||||
@ -21,6 +22,19 @@ print $process->getOutput();
|
|||||||
You can think that this is easy to achieve with plain PHP but it's not especially
|
You can think that this is easy to achieve with plain PHP but it's not especially
|
||||||
if you want to take care of the subtle differences between the different platforms.
|
if you want to take care of the subtle differences between the different platforms.
|
||||||
|
|
||||||
|
You can simplify the code by using `mustRun()` instead of `run()`, which will
|
||||||
|
throw a `ProcessFailedException` automatically in case of a problem:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
|
$process = new Process('ls -lsa');
|
||||||
|
$process->setTimeout(3600);
|
||||||
|
$process->mustRun();
|
||||||
|
|
||||||
|
print $process->getOutput();
|
||||||
|
```
|
||||||
|
|
||||||
And if you want to be able to get some feedback in real-time, just pass an
|
And if you want to be able to get some feedback in real-time, just pass an
|
||||||
anonymous function to the ``run()`` method and you will get the output buffer
|
anonymous function to the ``run()`` method and you will get the output buffer
|
||||||
as it becomes available:
|
as it becomes available:
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Routing\Tests\Generator\Dumper;
|
namespace Symfony\Component\Routing\Tests\Generator\Dumper;
|
||||||
|
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
|
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
|
||||||
@ -64,10 +65,10 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php'));
|
$projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php'));
|
||||||
|
|
||||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), true);
|
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), true);
|
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), false);
|
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), false);
|
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
|
|
||||||
$this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
|
$this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
|
||||||
$this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
|
$this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
|
||||||
|
@ -22,7 +22,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAbsoluteUrlWithPort80()
|
public function testAbsoluteUrlWithPort80()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array(), true);
|
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$this->assertEquals('http://localhost/app.php/testing', $url);
|
$this->assertEquals('http://localhost/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAbsoluteSecureUrlWithPort443()
|
public function testAbsoluteSecureUrlWithPort443()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', array(), true);
|
$url = $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$this->assertEquals('https://localhost/app.php/testing', $url);
|
$this->assertEquals('https://localhost/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAbsoluteUrlWithNonStandardPort()
|
public function testAbsoluteUrlWithNonStandardPort()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes, array('httpPort' => 8080))->generate('test', array(), true);
|
$url = $this->getGenerator($routes, array('httpPort' => 8080))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$this->assertEquals('http://localhost:8080/app.php/testing', $url);
|
$this->assertEquals('http://localhost:8080/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAbsoluteSecureUrlWithNonStandardPort()
|
public function testAbsoluteSecureUrlWithNonStandardPort()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes, array('httpsPort' => 8080, 'scheme' => 'https'))->generate('test', array(), true);
|
$url = $this->getGenerator($routes, array('httpsPort' => 8080, 'scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$this->assertEquals('https://localhost:8080/app.php/testing', $url);
|
$this->assertEquals('https://localhost:8080/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testRelativeUrlWithoutParameters()
|
public function testRelativeUrlWithoutParameters()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array(), false);
|
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
|
|
||||||
$this->assertEquals('/app.php/testing', $url);
|
$this->assertEquals('/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testRelativeUrlWithParameter()
|
public function testRelativeUrlWithParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), false);
|
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
|
|
||||||
$this->assertEquals('/app.php/testing/bar', $url);
|
$this->assertEquals('/app.php/testing/bar', $url);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testRelativeUrlWithNullParameter()
|
public function testRelativeUrlWithNullParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing.{format}', array('format' => null)));
|
$routes = $this->getRoutes('test', new Route('/testing.{format}', array('format' => null)));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array(), false);
|
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
|
|
||||||
$this->assertEquals('/app.php/testing', $url);
|
$this->assertEquals('/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -83,13 +83,13 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', array('foo' => null)));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', array('foo' => null)));
|
||||||
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
|
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
|
||||||
// Generating path "/testing//bar" would be wrong as matching this route would fail.
|
// Generating path "/testing//bar" would be wrong as matching this route would fail.
|
||||||
$this->getGenerator($routes)->generate('test', array(), false);
|
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRelativeUrlWithOptionalZeroParameter()
|
public function testRelativeUrlWithOptionalZeroParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing/{page}'));
|
$routes = $this->getRoutes('test', new Route('/testing/{page}'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array('page' => 0), false);
|
$url = $this->getGenerator($routes)->generate('test', array('page' => 0), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
|
|
||||||
$this->assertEquals('/app.php/testing/0', $url);
|
$this->assertEquals('/app.php/testing/0', $url);
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testRelativeUrlWithExtraParameters()
|
public function testRelativeUrlWithExtraParameters()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), false);
|
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
|
|
||||||
$this->assertEquals('/app.php/testing?foo=bar', $url);
|
$this->assertEquals('/app.php/testing?foo=bar', $url);
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAbsoluteUrlWithExtraParameters()
|
public function testAbsoluteUrlWithExtraParameters()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), true);
|
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$this->assertEquals('http://localhost/app.php/testing?foo=bar', $url);
|
$this->assertEquals('http://localhost/app.php/testing?foo=bar', $url);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testUrlWithNullExtraParameters()
|
public function testUrlWithNullExtraParameters()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => null), true);
|
$url = $this->getGenerator($routes)->generate('test', array('foo' => null), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$this->assertEquals('http://localhost/app.php/testing', $url);
|
$this->assertEquals('http://localhost/app.php/testing', $url);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGenerateWithoutRoutes()
|
public function testGenerateWithoutRoutes()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('foo', new Route('/testing/{foo}'));
|
$routes = $this->getRoutes('foo', new Route('/testing/{foo}'));
|
||||||
$this->getGenerator($routes)->generate('test', array(), true);
|
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,7 +176,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGenerateForRouteWithoutMandatoryParameter()
|
public function testGenerateForRouteWithoutMandatoryParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||||
$this->getGenerator($routes)->generate('test', array(), true);
|
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,7 +185,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGenerateForRouteWithInvalidOptionalParameter()
|
public function testGenerateForRouteWithInvalidOptionalParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||||
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), true);
|
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,7 +194,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGenerateForRouteWithInvalidParameter()
|
public function testGenerateForRouteWithInvalidParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '1|2')));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '1|2')));
|
||||||
$this->getGenerator($routes)->generate('test', array('foo' => '0'), true);
|
$this->getGenerator($routes)->generate('test', array('foo' => '0'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateForRouteWithInvalidOptionalParameterNonStrict()
|
public function testGenerateForRouteWithInvalidOptionalParameterNonStrict()
|
||||||
@ -202,7 +202,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||||
$generator = $this->getGenerator($routes);
|
$generator = $this->getGenerator($routes);
|
||||||
$generator->setStrictRequirements(false);
|
$generator->setStrictRequirements(false);
|
||||||
$this->assertNull($generator->generate('test', array('foo' => 'bar'), true));
|
$this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
|
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
|
||||||
@ -213,7 +213,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('error');
|
->method('error');
|
||||||
$generator = $this->getGenerator($routes, array(), $logger);
|
$generator = $this->getGenerator($routes, array(), $logger);
|
||||||
$generator->setStrictRequirements(false);
|
$generator->setStrictRequirements(false);
|
||||||
$this->assertNull($generator->generate('test', array('foo' => 'bar'), true));
|
$this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()
|
public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()
|
||||||
@ -230,7 +230,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGenerateForRouteWithInvalidMandatoryParameter()
|
public function testGenerateForRouteWithInvalidMandatoryParameter()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => 'd+')));
|
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => 'd+')));
|
||||||
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), true);
|
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -411,7 +411,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||||
|
|
||||||
$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));
|
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -420,7 +420,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testUrlWithInvalidParameterInHost()
|
public function testUrlWithInvalidParameterInHost()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false);
|
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,7 +429,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
|
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false);
|
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -438,7 +438,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testUrlWithInvalidParameterEqualsDefaultValueInHost()
|
public function testUrlWithInvalidParameterEqualsDefaultValueInHost()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), false);
|
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUrlWithInvalidParameterInHostInNonStrictMode()
|
public function testUrlWithInvalidParameterInHostInNonStrictMode()
|
||||||
@ -446,7 +446,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||||
$generator = $this->getGenerator($routes);
|
$generator = $this->getGenerator($routes);
|
||||||
$generator->setStrictRequirements(false);
|
$generator->setStrictRequirements(false);
|
||||||
$this->assertNull($generator->generate('test', array('foo' => 'baz'), false));
|
$this->assertNull($generator->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHostIsCaseInsensitive()
|
public function testHostIsCaseInsensitive()
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Security\Http\HttpUtils;
|
use Symfony\Component\Security\Http\HttpUtils;
|
||||||
|
|
||||||
class HttpUtilsTest extends \PHPUnit_Framework_TestCase
|
class HttpUtilsTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -43,7 +44,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
|
|||||||
$urlGenerator
|
$urlGenerator
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('generate')
|
->method('generate')
|
||||||
->with('foobar', array(), true)
|
->with('foobar', array(), UrlGeneratorInterface::ABSOLUTE_URL)
|
||||||
->will($this->returnValue('http://localhost/foo/bar'))
|
->will($this->returnValue('http://localhost/foo/bar'))
|
||||||
;
|
;
|
||||||
$urlGenerator
|
$urlGenerator
|
||||||
|
@ -34,7 +34,7 @@ class UrlValidator extends ConstraintValidator
|
|||||||
\] # a IPv6 address
|
\] # a IPv6 address
|
||||||
)
|
)
|
||||||
(:[0-9]+)? # a port (optional)
|
(:[0-9]+)? # a port (optional)
|
||||||
(/?|/\S+) # a /, nothing or a / with something
|
(/?|/\S+|\?|\#) # a /, nothing, a / with something, a query or a fragment
|
||||||
$~ixu';
|
$~ixu';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +117,8 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
array('http://☎.com/'),
|
array('http://☎.com/'),
|
||||||
array('http://username:password@symfony.com'),
|
array('http://username:password@symfony.com'),
|
||||||
array('http://user-name@symfony.com'),
|
array('http://user-name@symfony.com'),
|
||||||
|
array('http://symfony.com?'),
|
||||||
|
array('http://symfony.com#'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,8 +149,6 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
array('http://goog_le.com'),
|
array('http://goog_le.com'),
|
||||||
array('http://google.com::aa'),
|
array('http://google.com::aa'),
|
||||||
array('http://google.com:aa'),
|
array('http://google.com:aa'),
|
||||||
array('http://symfony.com?'),
|
|
||||||
array('http://symfony.com#'),
|
|
||||||
array('ftp://google.fr'),
|
array('ftp://google.fr'),
|
||||||
array('faked://google.fr'),
|
array('faked://google.fr'),
|
||||||
array('http://127.0.0.1:aa/'),
|
array('http://127.0.0.1:aa/'),
|
||||||
|
Reference in New Issue
Block a user