Merge branch '2.4'

* 2.4:
  Update MimeTypeExtensionGuesser.php
  [Validator] Add missing polish translations
  [Validator] Added missing strings from Image validator
  [Templating] PhpEngine should propagate charset to its helpers
  Fix ticket #10663 - Added setCharset method call to PHP templating engine.
  Changed the typehint of the EsiFragmentRenderer to the interface
  [Form] Improved test coverage of UrlType
  [BrowserKit] Fix #10641 : BrowserKit is broken when using ip as host
This commit is contained in:
Fabien Potencier 2014-04-10 15:01:02 +02:00
commit a45e464bc3
11 changed files with 99 additions and 7 deletions

View File

@ -15,6 +15,7 @@
<argument type="service" id="templating.loader" />
<argument type="service" id="debug.stopwatch" />
<argument type="service" id="templating.globals" />
<call method="setCharset"><argument>%kernel.charset%</argument></call>
</service>
</services>
</container>

View File

@ -297,7 +297,7 @@ abstract class Client
$uri = $this->getAbsoluteUri($uri);
if (isset($server['HTTP_HOST'])) {
$uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '\\1'.$server['HTTP_HOST'], $uri);
$uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '${1}'.$server['HTTP_HOST'], $uri);
}
if (isset($server['HTTPS'])) {

View File

@ -103,6 +103,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
}
public function testGetRequestWithIpAsHost()
{
$client = new TestClient();
$client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1'));
$this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri());
}
public function testGetResponse()
{
$client = new TestClient();

View File

@ -47,6 +47,18 @@ class UrlTypeTest extends TypeTestCase
$this->assertSame('', $form->getViewData());
}
public function testSubmitAddsNoDefaultProtocolIfNull()
{
$form = $this->factory->create('url', null, array(
'default_protocol' => 'http',
));
$form->submit(null);
$this->assertNull($form->getData());
$this->assertSame('', $form->getViewData());
}
public function testSubmitAddsNoDefaultProtocolIfSetToNull()
{
$form = $this->factory->create('url', null, array(

View File

@ -655,6 +655,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
'chemical/x-csml' => 'csml',
'chemical/x-xyz' => 'xyz',
'image/bmp' => 'bmp',
'image/x-ms-bmp' => 'bmp',
'image/cgm' => 'cgm',
'image/g3fax' => 'g3',
'image/gif' => 'gif',

View File

@ -32,8 +32,8 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer
* The "fallback" strategy when ESI is not available should always be an
* instance of InlineFragmentRenderer.
*
* @param Esi $esi An Esi instance
* @param InlineFragmentRenderer $inlineStrategy The inline strategy to use when ESI is not supported
* @param Esi $esi An Esi instance
* @param FragmentRendererInterface $inlineStrategy The inline strategy to use when ESI is not supported
*/
public function __construct(Esi $esi = null, InlineFragmentRenderer $inlineStrategy)
{

View File

@ -32,6 +32,9 @@ class PhpEngine implements EngineInterface, \ArrayAccess
{
protected $loader;
protected $current;
/**
* @var HelperInterface[]
*/
protected $helpers = array();
protected $parents = array();
protected $stack = array();
@ -364,6 +367,10 @@ class PhpEngine implements EngineInterface, \ArrayAccess
public function setCharset($charset)
{
$this->charset = $charset;
foreach ($this->helpers as $helper) {
$helper->setCharset($this->charset);
}
}
/**

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\Templating\Tests;
use Symfony\Component\Templating\PhpEngine;
use Symfony\Component\Templating\Loader\Loader;
use Symfony\Component\Templating\Storage\Storage;
use Symfony\Component\Templating\Storage\StringStorage;
use Symfony\Component\Templating\Helper\SlotsHelper;
use Symfony\Component\Templating\TemplateNameParser;
@ -152,10 +151,14 @@ class PhpEngineTest extends \PHPUnit_Framework_TestCase
public function testGetSetCharset()
{
$engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader);
$this->assertEquals('UTF-8', $engine->getCharset(), '->getCharset() returns UTF-8 by default');
$helper = new SlotsHelper();
$engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader, array($helper));
$this->assertEquals('UTF-8', $engine->getCharset(), 'EngineInterface::getCharset() returns UTF-8 by default');
$this->assertEquals('UTF-8', $helper->getCharset(), 'HelperInterface::getCharset() returns UTF-8 by default');
$engine->setCharset('ISO-8859-1');
$this->assertEquals('ISO-8859-1', $engine->getCharset(), '->setCharset() changes the default charset to use');
$this->assertEquals('ISO-8859-1', $engine->getCharset(), 'EngineInterface::setCharset() changes the default charset to use');
$this->assertEquals('ISO-8859-1', $helper->getCharset(), 'EngineInterface::setCharset() changes the default charset of helper');
}
public function testGlobalVariables()

View File

@ -278,6 +278,26 @@
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -278,6 +278,26 @@
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>Este valor no debería ser idéntico a {{ compared_value_type }} {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>La proporción de la imagen es demasiado grande ({{ ratio }}). Maxima proporción permitida es {{ max_ratio }}.</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>La proporción de la imagen es demasiado pequeña ({{ ratio }}). Mínima proporción permitida es {{ min_ratio }}.</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>La imagen es cuadrada ({{ width }}x{{ height }}px). Imágenes cuadradas no son permitidas.</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>La imagen está orientada horizontal ({{ width }}x{{ height }}px). Imágenes orientada horizontal no está permitido.</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>La imagen está orientada vertical ({{ width }}x{{ height }}px). Imágenes orientada vertical no está permitido.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -278,6 +278,26 @@
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>Ta wartość nie powinna być identycznego typu {{ compared_value_type }} oraz wartości {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>Proporcje obrazu są zbyt duże ({{ ratio }}). Maksymalne proporcje to {{ max_ratio }}.</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>Proporcje obrazu są zbyt małe ({{ ratio }}). Minimalne proporcje to {{ min_ratio }}.</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>Obraz jest kwadratem ({{ width }}x{{ height }}px). Kwadratowe obrazy nie są akceptowane.</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>Obraz jest panoramiczny ({{ width }}x{{ height }}px). Panoramiczne zdjęcia nie są akceptowane.</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>Obraz jest portretowy ({{ width }}x{{ height }}px). Portretowe zdjęcia nie są akceptowane.</target>
</trans-unit>
</body>
</file>
</xliff>