Merge branch '2.4' into 2.5

* 2.4:
  Fixed relative redirects for ambiguous paths
  [BrowserKit] Fix browser kit redirect with ports
  [TwigBridge] [Form] Fixed some extra empty spaces
  Plural fix
  removed some .gitattributes that should have been removed a lot time ago
  [DependencyInjection] fixed missing 'factory-class' attribute in XmlDumper output
  fixed whitespace in Twig form template
  built-in server: exit when docroot does not exist

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml
This commit is contained in:
Fabien Potencier 2014-08-06 08:44:37 +02:00
commit 6f07919307
10 changed files with 131 additions and 88 deletions

View File

@ -54,7 +54,7 @@
{% block choice_widget_collapsed -%}
{% if required and empty_value is none and not empty_value_in_choices and not multiple -%}
{% set required = false %}
{% endif %}
{%- endif -%}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{% if empty_value is not none -%}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>

View File

@ -82,6 +82,14 @@ EOF
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$documentRoot = $input->getOption('docroot');
if (!is_dir($documentRoot)) {
$output->writeln(sprintf('<error>The given document root directory "%s" does not exist</error>', $documentRoot));
return 1;
}
$env = $this->getContainer()->getParameter('kernel.environment');
if ('prod' === $env) {
@ -91,7 +99,7 @@ EOF
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
$builder = $this->createPhpProcessBuilder($input, $output, $env);
$builder->setWorkingDirectory($input->getOption('docroot'));
$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$process = $builder->getProcess();

View File

@ -296,7 +296,7 @@ abstract class Client
$uri = $this->getAbsoluteUri($uri);
if (isset($server['HTTP_HOST'])) {
if (!empty($server['HTTP_HOST'])) {
$uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri);
}
@ -598,7 +598,7 @@ abstract class Client
private function updateServerFromUri($server, $uri)
{
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
$server['HTTP_HOST'] = $this->extractHost($uri);
$scheme = parse_url($uri, PHP_URL_SCHEME);
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);

View File

@ -367,6 +367,19 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
}
public function testFollowRelativeRedirect()
{
$client = new TestClient();
$client->setNextResponse(new Response('', 302, array('Location' => '/redirected')));
$client->request('GET', 'http://www.example.com/foo/foobar');
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any');
$client = new TestClient();
$client->setNextResponse(new Response('', 302, array('Location' => '/redirected:1234')));
$client->request('GET', 'http://www.example.com/foo/foobar');
$this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls');
}
public function testFollowRedirectWithMaxRedirects()
{
$client = new TestClient();
@ -452,11 +465,11 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$headers = array(
'HTTP_HOST' => 'www.example.com:8080',
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
'HTTPS' => false
'HTTPS' => false,
'HTTP_REFERER' => 'http://www.example.com:8080/'
);
$client = new TestClient();
$client->followRedirects(false);
$client->setNextResponse(new Response('', 302, array(
'Location' => 'http://www.example.com:8080/redirected',
)));

View File

@ -120,6 +120,9 @@ class XmlDumper extends Dumper
if ($definition->getFactoryMethod()) {
$service->setAttribute('factory-method', $definition->getFactoryMethod());
}
if ($definition->getFactoryClass()) {
$service->setAttribute('factory-class', $definition->getFactoryClass());
}
if ($definition->getFactoryService()) {
$service->setAttribute('factory-service', $definition->getFactoryService());
}

View File

@ -6,7 +6,7 @@
<parameter key="foo">bar</parameter>
</parameters>
<services>
<service id="foo" class="Bar\FooClass" factory-method="getInstance">
<service id="foo" class="Bar\FooClass" factory-method="getInstance" factory-class="Bar\FooClass">
<tag name="foo" foo="foo"/>
<tag name="foo" bar="bar"/>
<argument>foo</argument>
@ -35,7 +35,7 @@
<argument>%foo_bar%</argument>
<configurator service="foo.baz" method="configure"/>
</service>
<service id="foo.baz" class="%baz_class%" factory-method="getInstance">
<service id="foo.baz" class="%baz_class%" factory-method="getInstance" factory-class="%baz_class%">
<configurator class="%baz_class%" method="configureStatic1"/>
</service>
<service id="foo_bar" class="%foo_class%" scope="prototype"/>

View File

@ -1,2 +0,0 @@
/Tests export-ignore
phpunit.xml.dist export-ignore

View File

@ -75,6 +75,9 @@ class StringUtil
// objectives (objective), alternative (alternatives)
array('sevit', 5, true, true, 'tive'),
// drives (drive)
array('sevird', 6, false, true, 'drive'),
// lives (life), wives (wife)
array('sevi', 4, false, true, 'ife'),

View File

@ -20,114 +20,127 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
// see http://english-zone.com/spelling/plurals.html
// see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English
return array(
array('tags', 'tag'),
array('accesses', 'access'),
array('addresses', 'address'),
array('agendas', 'agenda'),
array('alumnae', 'alumna'),
array('alumni', 'alumnus'),
array('funguses', array('fungus', 'funguse', 'fungusis')),
array('fungi', 'fungus'),
array('axes', array('ax', 'axe', 'axis')),
array('appendices', array('appendex', 'appendix', 'appendice')),
array('indices', array('index', 'indix', 'indice')),
array('prices', array('prex', 'prix', 'price')),
array('indexes', 'index'),
array('children', 'child'),
array('men', 'man'),
array('women', 'woman'),
array('oxen', 'ox'),
array('bacteria', array('bacterion', 'bacterium')),
array('criteria', array('criterion', 'criterium')),
array('feet', 'foot'),
array('nebulae', 'nebula'),
array('babies', 'baby'),
array('hooves', array('hoof', 'hoove', 'hooff')),
array('chateaux', 'chateau'),
array('echoes', array('echo', 'echoe')),
array('analyses', array('analys', 'analyse', 'analysis')),
array('theses', array('thes', 'these', 'thesis')),
array('foci', 'focus'),
array('focuses', array('focus', 'focuse', 'focusis')),
array('oases', array('oas', 'oase', 'oasis')),
array('matrices', array('matrex', 'matrix', 'matrice')),
array('matrixes', 'matrix'),
array('bureaus', 'bureau'),
array('bureaux', 'bureau'),
array('beaux', 'beau'),
array('data', array('daton', 'datum')),
array('phenomena', array('phenomenon', 'phenomenum')),
array('strata', array('straton', 'stratum')),
array('geese', 'goose'),
array('teeth', 'tooth'),
array('antennae', 'antenna'),
array('antennas', 'antenna'),
array('houses', array('hous', 'house', 'housis')),
array('appendices', array('appendex', 'appendix', 'appendice')),
array('arches', array('arch', 'arche')),
array('atlases', array('atlas', 'atlase', 'atlasis')),
array('axes', array('ax', 'axe', 'axis')),
array('babies', 'baby'),
array('bacteria', array('bacterion', 'bacterium')),
array('bases', array('bas', 'base', 'basis')),
array('batches', array('batch', 'batche')),
array('bushes', array('bush', 'bushe')),
array('beaux', 'beau'),
array('bees', array('be', 'bee')),
array('boxes', 'box'),
array('boys', 'boy'),
array('bureaus', 'bureau'),
array('bureaux', 'bureau'),
array('buses', array('bus', 'buse', 'busis')),
array('bushes', array('bush', 'bushe')),
array('calves', array('calf', 'calve', 'calff')),
array('cars', 'car'),
array('cassettes', array('cassett', 'cassette')),
array('caves', array('caf', 'cave', 'caff')),
array('chateaux', 'chateau'),
array('cheeses', array('chees', 'cheese', 'cheesis')),
array('children', 'child'),
array('circuses', array('circus', 'circuse', 'circusis')),
array('cliffs', 'cliff'),
array('crises', array('cris', 'crise', 'crisis')),
array('criteria', array('criterion', 'criterium')),
array('cups', 'cup'),
array('data', array('daton', 'datum')),
array('days', 'day'),
array('discos', 'disco'),
array('drives', 'drive'),
array('drivers', 'driver'),
array('dwarves', array('dwarf', 'dwarve', 'dwarff')),
array('echoes', array('echo', 'echoe')),
array('elves', array('elf', 'elve', 'elff')),
array('emphases', array('emphas', 'emphase', 'emphasis')),
array('faxes', 'fax'),
array('feet', 'foot'),
array('foci', 'focus'),
array('focuses', array('focus', 'focuse', 'focusis')),
array('formulae', 'formula'),
array('formulas', 'formula'),
array('fungi', 'fungus'),
array('funguses', array('fungus', 'funguse', 'fungusis')),
array('garages', array('garag', 'garage')),
array('geese', 'goose'),
array('halves', array('half', 'halve', 'halff')),
array('hats', 'hat'),
array('heroes', array('hero', 'heroe')),
array('hippopotamuses', array('hippopotamus', 'hippopotamuse', 'hippopotamusis')), //hippopotami
array('hoaxes', 'hoax'),
array('hooves', array('hoof', 'hoove', 'hooff')),
array('houses', array('hous', 'house', 'housis')),
array('indexes', 'index'),
array('indices', array('index', 'indix', 'indice')),
array('ions', 'ion'),
array('irises', array('iris', 'irise', 'irisis')),
array('kisses', 'kiss'),
array('addresses', 'address'),
array('accesses', 'access'),
array('knives', 'knife'),
array('lives', 'life'),
array('lamps', 'lamp'),
array('leaves', array('leaf', 'leave', 'leaff')),
array('lice', 'louse'),
array('lives', 'life'),
array('matrices', array('matrex', 'matrix', 'matrice')),
array('matrixes', 'matrix'),
array('men', 'man'),
array('mice', 'mouse'),
array('moves', 'move'),
array('nebulae', 'nebula'),
array('neuroses', array('neuros', 'neurose', 'neurosis')),
array('oases', array('oas', 'oase', 'oasis')),
array('objectives', 'objective'),
array('oxen', 'ox'),
array('parties', 'party'),
array('phenomena', array('phenomenon', 'phenomenum')),
array('photos', 'photo'),
array('pianos', 'piano'),
array('plateaux', 'plateau'),
array('poppies', 'poppy'),
array('prices', array('prex', 'prix', 'price')),
array('quizzes', 'quiz'),
array('scarves', array('scarf', 'scarve', 'scarff')),
array('spies', 'spy'),
array('stories', 'story'),
array('syllabi', 'syllabus'),
array('thieves', array('thief', 'thieve', 'thieff')),
array('waltzes', array('waltz', 'waltze')),
array('wharves', array('wharf', 'wharve', 'wharff')),
array('caves', array('caf', 'cave', 'caff')),
array('staves', array('staf', 'stave', 'staff')),
array('wives', 'wife'),
array('ions', 'ion'),
array('bases', array('bas', 'base', 'basis')),
array('cars', 'car'),
array('cassettes', array('cassett', 'cassette')),
array('lamps', 'lamp'),
array('hats', 'hat'),
array('cups', 'cup'),
array('boxes', 'box'),
array('sandwiches', array('sandwich', 'sandwiche')),
array('suitcases', array('suitcas', 'suitcase', 'suitcasis')),
array('roses', array('ros', 'rose', 'rosis')),
array('garages', array('garag', 'garage')),
array('shoes', array('sho', 'shoe')),
array('days', 'day'),
array('boys', 'boy'),
array('roofs', 'roof'),
array('cliffs', 'cliff'),
array('sheriffs', 'sheriff'),
array('discos', 'disco'),
array('pianos', 'piano'),
array('photos', 'photo'),
array('trees', array('tre', 'tree')),
array('bees', array('be', 'bee')),
array('cheeses', array('chees', 'cheese', 'cheesis')),
array('radii', 'radius'),
array('objectives', 'objective'),
array('moves', 'move'),
array('roofs', 'roof'),
array('roses', array('ros', 'rose', 'rosis')),
array('sandwiches', array('sandwich', 'sandwiche')),
array('scarves', array('scarf', 'scarve', 'scarff')),
array('schemas', 'schema'), //schemata
array('sheriffs', 'sheriff'),
array('shoes', array('sho', 'shoe')),
array('spies', 'spy'),
array('staves', array('staf', 'stave', 'staff')),
array('stories', 'story'),
array('strata', array('straton', 'stratum')),
array('suitcases', array('suitcas', 'suitcase', 'suitcasis')),
array('syllabi', 'syllabus'),
array('tags', 'tag'),
array('teeth', 'tooth'),
array('theses', array('thes', 'these', 'thesis')),
array('thieves', array('thief', 'thieve', 'thieff')),
array('trees', array('tre', 'tree')),
array('waltzes', array('waltz', 'waltze')),
array('wives', 'wife'),
// test casing: if the first letter was uppercase, it should remain so
array('Men', 'Man'),
array('GrandChildren', 'GrandChild'),
array('SubTrees', array('SubTre', 'SubTree')),
// Known issues
//array('insignia', 'insigne'),
//array('insignias', 'insigne'),
//array('rattles', 'rattle'),
);
}
@ -136,6 +149,13 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
*/
public function testSingularify($plural, $singular)
{
$this->assertEquals($singular, StringUtil::singularify($plural));
$single = StringUtil::singularify($plural);
if (is_string($singular) && is_array($single)) {
$this->fail("--- Expected\n`string`: " . $singular . "\n+++ Actual\n`array`: " . implode(', ', $single));
} elseif (is_array($singular) && is_string($single)) {
$this->fail("--- Expected\n`array`: " . implode(', ', $singular) . "\n+++ Actual\n`string`: " . $single);
}
$this->assertEquals($singular, $single);
}
}

View File

@ -1,2 +0,0 @@
Tests/ export-ignore
phpunit.xml.dist export-ignore