[Routing] renamed hostname pattern to just hostname
This commit is contained in:
parent
e803f4663c
commit
b357cafd00
@ -92,7 +92,7 @@ EOF
|
||||
? implode(', ', $requirements['_method']) : $requirements['_method']
|
||||
)
|
||||
: 'ANY';
|
||||
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
|
||||
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
|
||||
$maxName = max($maxName, strlen($name));
|
||||
$maxMethod = max($maxMethod, strlen($method));
|
||||
$maxHostname = max($maxHostname, strlen($hostname));
|
||||
@ -109,7 +109,7 @@ EOF
|
||||
? implode(', ', $requirements['_method']) : $requirements['_method']
|
||||
)
|
||||
: 'ANY';
|
||||
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
|
||||
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
|
||||
$output->writeln(sprintf($format, $name, $method, $hostname, $route->getPattern()));
|
||||
}
|
||||
}
|
||||
@ -124,13 +124,13 @@ EOF
|
||||
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
$hostname = '' !== $route->getHostnamePattern() ? $route->getHostnamePattern() : 'ANY';
|
||||
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
|
||||
|
||||
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
|
||||
|
||||
$output->writeln(sprintf('<comment>Name</comment> %s', $name));
|
||||
$output->writeln(sprintf('<comment>Pattern</comment> %s', $route->getPattern()));
|
||||
$output->writeln(sprintf('<comment>HostnamePattern</comment> %s', $hostname));
|
||||
$output->writeln(sprintf('<comment>Hostname</comment> %s', $hostname));
|
||||
$output->writeln(sprintf('<comment>Class</comment> %s', get_class($route)));
|
||||
|
||||
$defaults = '';
|
||||
|
@ -78,7 +78,7 @@ class Router extends BaseRouter implements WarmableInterface
|
||||
* - the route defaults,
|
||||
* - the route requirements,
|
||||
* - the route pattern.
|
||||
* - the route hostnamePattern.
|
||||
* - the route hostname.
|
||||
*
|
||||
* @param RouteCollection $collection
|
||||
*/
|
||||
@ -94,7 +94,7 @@ class Router extends BaseRouter implements WarmableInterface
|
||||
}
|
||||
|
||||
$route->setPattern($this->resolve($route->getPattern()));
|
||||
$route->setHostnamePattern($this->resolve($route->getHostnamePattern()));
|
||||
$route->setHostname($this->resolve($route->getHostname()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,12 +117,12 @@ class RoutingTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testHostnamePatternPlaceholders()
|
||||
public function testHostnamePlaceholders()
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$route = new Route('foo');
|
||||
$route->setHostnamePattern('/before/%parameter.foo%/after/%%unescaped%%');
|
||||
$route->setHostname('/before/%parameter.foo%/after/%%unescaped%%');
|
||||
|
||||
$routes->add('foo', $route);
|
||||
|
||||
@ -136,7 +136,7 @@ class RoutingTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
'/before/foo/after/%unescaped%',
|
||||
$route->getHostnamePattern()
|
||||
$route->getHostname()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Route
|
||||
private $requirements;
|
||||
private $options;
|
||||
private $defaults;
|
||||
private $hostnamePattern;
|
||||
private $hostname;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -62,14 +62,14 @@ class Route
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
public function setHostnamePattern($pattern)
|
||||
public function setHostname($pattern)
|
||||
{
|
||||
$this->hostnamePattern = $pattern;
|
||||
$this->hostname = $pattern;
|
||||
}
|
||||
|
||||
public function getHostnamePattern()
|
||||
public function getHostname()
|
||||
{
|
||||
return $this->hostnamePattern;
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
|
@ -112,7 +112,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'hostname_pattern' => '',
|
||||
'hostname' => '',
|
||||
);
|
||||
|
||||
$class = new \ReflectionClass($class);
|
||||
@ -137,8 +137,8 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
$globals['defaults'] = $annot->getDefaults();
|
||||
}
|
||||
|
||||
if (null !== $annot->getHostnamePattern()) {
|
||||
$globals['hostname_pattern'] = $annot->getHostnamePattern();
|
||||
if (null !== $annot->getHostname()) {
|
||||
$globals['hostname'] = $annot->getHostname();
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,12 +173,12 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
$requirements = array_replace($globals['requirements'], $annot->getRequirements());
|
||||
$options = array_replace($globals['options'], $annot->getOptions());
|
||||
|
||||
$hostnamePattern = $annot->getHostnamePattern();
|
||||
if (null === $hostnamePattern) {
|
||||
$hostnamePattern = $globals['hostname_pattern'];
|
||||
$hostname = $annot->getHostname();
|
||||
if (null === $hostname) {
|
||||
$hostname = $globals['hostname'];
|
||||
}
|
||||
|
||||
$route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options, $hostnamePattern);
|
||||
$route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options, $hostname);
|
||||
|
||||
$this->configureRoute($route, $class, $method, $annot);
|
||||
|
||||
|
@ -121,7 +121,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
|
||||
|
||||
$route = new Route($node->getAttribute('pattern'), $defaults, $requirements, $options, $node->getAttribute('hostname-pattern'), $schemes, $methods);
|
||||
$route = new Route($node->getAttribute('pattern'), $defaults, $requirements, $options, $node->getAttribute('hostname'), $schemes, $methods);
|
||||
$collection->add($id, $route);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ class XmlFileLoader extends FileLoader
|
||||
|
||||
$type = $node->getAttribute('type');
|
||||
$prefix = $node->getAttribute('prefix');
|
||||
$hostnamePattern = $node->hasAttribute('hostname-pattern') ? $node->getAttribute('hostname-pattern') : null;
|
||||
$hostname = $node->hasAttribute('hostname') ? $node->getAttribute('hostname') : null;
|
||||
$schemes = $node->hasAttribute('schemes') ? array_filter(explode(' ', $node->getAttribute('schemes'))) : null;
|
||||
$methods = $node->hasAttribute('methods') ? array_filter(explode(' ', $node->getAttribute('methods'))) : null;
|
||||
|
||||
@ -154,8 +154,8 @@ class XmlFileLoader extends FileLoader
|
||||
$subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file);
|
||||
/* @var $subCollection RouteCollection */
|
||||
$subCollection->addPrefix($prefix);
|
||||
if (null !== $hostnamePattern) {
|
||||
$subCollection->setHostnamePattern($hostnamePattern);
|
||||
if (null !== $hostname) {
|
||||
$subCollection->setHostname($hostname);
|
||||
}
|
||||
if (null !== $schemes) {
|
||||
$subCollection->setSchemes($schemes);
|
||||
|
@ -28,7 +28,7 @@ use Symfony\Component\Config\Loader\FileLoader;
|
||||
class YamlFileLoader extends FileLoader
|
||||
{
|
||||
private static $availableKeys = array(
|
||||
'resource', 'type', 'prefix', 'pattern', 'hostname_pattern', 'schemes', 'methods', 'defaults', 'requirements', 'options',
|
||||
'resource', 'type', 'prefix', 'pattern', 'hostname', 'schemes', 'methods', 'defaults', 'requirements', 'options',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -98,11 +98,11 @@ class YamlFileLoader extends FileLoader
|
||||
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
||||
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
||||
$options = isset($config['options']) ? $config['options'] : array();
|
||||
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : '';
|
||||
$hostname = isset($config['hostname']) ? $config['hostname'] : '';
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : array();
|
||||
$methods = isset($config['methods']) ? $config['methods'] : array();
|
||||
|
||||
$route = new Route($config['pattern'], $defaults, $requirements, $options, $hostnamePattern, $schemes, $methods);
|
||||
$route = new Route($config['pattern'], $defaults, $requirements, $options, $hostname, $schemes, $methods);
|
||||
|
||||
$collection->add($name, $route);
|
||||
}
|
||||
@ -122,7 +122,7 @@ class YamlFileLoader extends FileLoader
|
||||
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
||||
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
||||
$options = isset($config['options']) ? $config['options'] : array();
|
||||
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;
|
||||
$hostname = isset($config['hostname']) ? $config['hostname'] : null;
|
||||
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
|
||||
$methods = isset($config['methods']) ? $config['methods'] : null;
|
||||
|
||||
@ -131,8 +131,8 @@ class YamlFileLoader extends FileLoader
|
||||
$subCollection = $this->import($config['resource'], $type, false, $file);
|
||||
/* @var $subCollection RouteCollection */
|
||||
$subCollection->addPrefix($prefix);
|
||||
if (null !== $hostnamePattern) {
|
||||
$subCollection->setHostnamePattern($hostnamePattern);
|
||||
if (null !== $hostname) {
|
||||
$subCollection->setHostname($hostname);
|
||||
}
|
||||
if (null !== $schemes) {
|
||||
$subCollection->setSchemes($schemes);
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
<xsd:attribute name="id" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="pattern" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="hostname-pattern" type="xsd:string" />
|
||||
<xsd:attribute name="hostname" type="xsd:string" />
|
||||
<xsd:attribute name="schemes" type="stringlist" />
|
||||
<xsd:attribute name="methods" type="stringlist" />
|
||||
</xsd:complexType>
|
||||
@ -58,7 +58,7 @@
|
||||
<xsd:attribute name="resource" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="prefix" type="xsd:string" />
|
||||
<xsd:attribute name="hostname-pattern" type="xsd:string" />
|
||||
<xsd:attribute name="hostname" type="xsd:string" />
|
||||
<xsd:attribute name="schemes" type="stringlist" />
|
||||
<xsd:attribute name="methods" type="stringlist" />
|
||||
</xsd:complexType>
|
||||
|
@ -29,7 +29,7 @@ class Route implements \Serializable
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $hostnamePattern = '';
|
||||
private $hostname = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@ -74,20 +74,19 @@ class Route implements \Serializable
|
||||
* @param array $defaults An array of default parameter values
|
||||
* @param array $requirements An array of requirements for parameters (regexes)
|
||||
* @param array $options An array of options
|
||||
* @param string $hostnamePattern The hostname pattern to match
|
||||
* @param string $hostname The hostname pattern to match
|
||||
* @param string|array $schemes A required URI scheme or an array of restricted schemes
|
||||
* @param string|array $methods A required HTTP method or an array of restricted methods
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array(),
|
||||
$hostnamePattern = '', $schemes = array(), $methods = array())
|
||||
public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array(), $hostname = '', $schemes = array(), $methods = array())
|
||||
{
|
||||
$this->setPattern($pattern);
|
||||
$this->setDefaults($defaults);
|
||||
$this->setRequirements($requirements);
|
||||
$this->setOptions($options);
|
||||
$this->setHostnamePattern($hostnamePattern);
|
||||
$this->setHostname($hostname);
|
||||
// The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement.
|
||||
// They can be removed when the BC layer is removed.
|
||||
if ($schemes) {
|
||||
@ -102,7 +101,7 @@ class Route implements \Serializable
|
||||
{
|
||||
return serialize(array(
|
||||
'pattern' => $this->pattern,
|
||||
'hostnamePattern' => $this->hostnamePattern,
|
||||
'hostname' => $this->hostname,
|
||||
'defaults' => $this->defaults,
|
||||
'requirements' => $this->requirements,
|
||||
'options' => $this->options,
|
||||
@ -115,7 +114,7 @@ class Route implements \Serializable
|
||||
{
|
||||
$data = unserialize($data);
|
||||
$this->pattern = $data['pattern'];
|
||||
$this->hostnamePattern = $data['hostnamePattern'];
|
||||
$this->hostname = $data['hostname'];
|
||||
$this->defaults = $data['defaults'];
|
||||
$this->requirements = $data['requirements'];
|
||||
$this->options = $data['options'];
|
||||
@ -157,9 +156,9 @@ class Route implements \Serializable
|
||||
*
|
||||
* @return string The pattern
|
||||
*/
|
||||
public function getHostnamePattern()
|
||||
public function getHostname()
|
||||
{
|
||||
return $this->hostnamePattern;
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,9 +166,9 @@ class Route implements \Serializable
|
||||
*
|
||||
* @param string $pattern The pattern
|
||||
*/
|
||||
public function setHostnamePattern($pattern)
|
||||
public function setHostname($pattern)
|
||||
{
|
||||
$this->hostnamePattern = (string) $pattern;
|
||||
$this->hostname = (string) $pattern;
|
||||
$this->compiled = null;
|
||||
|
||||
return $this;
|
||||
|
@ -261,10 +261,10 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
||||
* @param array $defaults An array of default values
|
||||
* @param array $requirements An array of requirements
|
||||
*/
|
||||
public function setHostnamePattern($pattern, array $defaults = array(), array $requirements = array())
|
||||
public function setHostname($pattern, array $defaults = array(), array $requirements = array())
|
||||
{
|
||||
foreach ($this->routes as $route) {
|
||||
$route->setHostnamePattern($pattern);
|
||||
$route->setHostname($pattern);
|
||||
$route->addDefaults($defaults);
|
||||
$route->addRequirements($requirements);
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$hostnameRegex = null;
|
||||
$hostnameTokens = array();
|
||||
|
||||
if ('' !== $hostnamePattern = $route->getHostnamePattern()) {
|
||||
$result = $this->compilePattern($route, $hostnamePattern, true);
|
||||
if ('' !== $hostname = $route->getHostname()) {
|
||||
$result = $this->compilePattern($route, $hostname, true);
|
||||
|
||||
$hostnameVariables = $result['variables'];
|
||||
$variables = array_merge($variables, $hostnameVariables);
|
||||
|
@ -40,7 +40,7 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'),
|
||||
array('name', 'blog_index', 'getName'),
|
||||
array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'),
|
||||
array('hostname_pattern', array('{locale}.example.com'), 'getHostnamePattern')
|
||||
array('hostname', array('{locale}.example.com'), 'getHostname')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<r:route id="blog_show" pattern="/blog/{slug}" hostname-pattern="{_locale}.example.com">
|
||||
<r:route id="blog_show" pattern="/blog/{slug}" hostname="{_locale}.example.com">
|
||||
<r:default key="_controller">MyBundle:Blog:show</r:default>
|
||||
<requirement xmlns="http://symfony.com/schema/routing" key="slug">\w+</requirement>
|
||||
<r2:requirement xmlns:r2="http://symfony.com/schema/routing" key="_locale">en|fr|de</r2:requirement>
|
||||
|
@ -4,7 +4,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" pattern="/blog/{slug}" hostname-pattern="{locale}.example.com">
|
||||
<route id="blog_show" pattern="/blog/{slug}" hostname="{locale}.example.com">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
<requirement key="_method">GET</requirement>
|
||||
<requirement key="locale">\w+</requirement>
|
||||
|
@ -1,7 +1,7 @@
|
||||
blog_show:
|
||||
pattern: /blog/{slug}
|
||||
defaults: { _controller: MyBlogBundle:Blog:show }
|
||||
hostname_pattern: "{locale}.example.com"
|
||||
hostname : "{locale}.example.com"
|
||||
requirements: { '_method': 'GET', 'locale': '\w+' }
|
||||
options:
|
||||
compiler_class: RouteCompiler
|
||||
|
@ -4,7 +4,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="validpattern.xml" prefix="/{foo}" hostname-pattern="{locale}.example.com">
|
||||
<import resource="validpattern.xml" prefix="/{foo}" hostname="{locale}.example.com">
|
||||
<default key="foo">123</default>
|
||||
<requirement key="foo">\d+</requirement>
|
||||
<option key="foo">bar</option>
|
||||
|
@ -4,4 +4,4 @@ blog_show:
|
||||
defaults: { 'foo': '123' }
|
||||
requirements: { 'foo': '\d+' }
|
||||
options: { 'foo': 'bar' }
|
||||
hostname_pattern: "{locale}.example.com"
|
||||
hostname: "{locale}.example.com"
|
||||
|
@ -46,7 +46,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('/blog/{slug}', $route->getPattern());
|
||||
$this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertEquals('GET', $route->getRequirement('_method'));
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostname());
|
||||
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertEquals('GET', $route->getRequirement('_method'));
|
||||
$this->assertEquals('\w+', $route->getRequirement('locale'));
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostname());
|
||||
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertEquals('\w+', $route->getRequirement('slug'));
|
||||
$this->assertEquals('en|fr|de', $route->getRequirement('_locale'));
|
||||
$this->assertEquals('{_locale}.example.com', $route->getHostnamePattern());
|
||||
$this->assertEquals('{_locale}.example.com', $route->getHostname());
|
||||
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
|
||||
$this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
|
||||
$this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
|
||||
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostname());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +86,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertEquals('GET', $route->getRequirement('_method'));
|
||||
$this->assertEquals('\w+', $route->getRequirement('locale'));
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostname());
|
||||
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
|
||||
}
|
||||
|
||||
@ -103,6 +103,6 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
|
||||
$this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
|
||||
$this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
|
||||
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostname());
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/{foo}'));
|
||||
$coll->add('bar', new Route('/bar/{foo}', array(), array(), array(), '{locale}.example.net'));
|
||||
$coll->setHostnamePattern('{locale}.example.com');
|
||||
$coll->setHostname('{locale}.example.com');
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar'));
|
||||
|
@ -224,7 +224,7 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($collection1->get(0), '->get() does not disclose internal child RouteCollection');
|
||||
}
|
||||
|
||||
public function testSetHostnamePattern()
|
||||
public function testSetHostname()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$routea = new Route('/a');
|
||||
@ -232,9 +232,9 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$collection->add('a', $routea);
|
||||
$collection->add('b', $routeb);
|
||||
|
||||
$collection->setHostnamePattern('{locale}.example.com');
|
||||
$collection->setHostname('{locale}.example.com');
|
||||
|
||||
$this->assertEquals('{locale}.example.com', $routea->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $routeb->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.com', $routea->getHostname());
|
||||
$this->assertEquals('{locale}.example.com', $routeb->getHostname());
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '__construct() takes defaults as its second argument');
|
||||
$this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '__construct() takes requirements as its third argument');
|
||||
$this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument');
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern(), '__construct() takes a hostname pattern as its fifth argument');
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostname(), '__construct() takes a hostname pattern as its fifth argument');
|
||||
|
||||
$route = new Route('/', array(), array(), array(), '', array('Https'), array('POST', 'put'));
|
||||
$this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes schemes as its sixth argument and lowercases it');
|
||||
@ -130,11 +130,11 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testHostnamePattern()
|
||||
public function testHostname()
|
||||
{
|
||||
$route = new Route('/');
|
||||
$route->setHostnamePattern('{locale}.example.net');
|
||||
$this->assertEquals('{locale}.example.net', $route->getHostnamePattern(), '->setHostnamePattern() sets the hostname pattern');
|
||||
$route->setHostname('{locale}.example.net');
|
||||
$this->assertEquals('{locale}.example.net', $route->getHostname(), '->setHostname() sets the hostname pattern');
|
||||
}
|
||||
|
||||
public function testScheme()
|
||||
|
Reference in New Issue
Block a user