Merge branch '4.2'

* 4.2:
  fix tests
  fix PHPUnit 4.8 compatibility
  [Debug] Fixed error handling when an error is already handled when another error is already handled (5)
  sync validator translations
This commit is contained in:
Christian Flothmann 2019-04-07 21:47:23 +02:00
commit 2efd7b2149
8 changed files with 85 additions and 52 deletions

View File

@ -114,7 +114,6 @@
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
{{- form_label(form) }} {# -#}
{{ form_widget(form, widget_attr) }} {# -#}
{{ form_widget(form) }} {# -#}
{{ form_errors(form) }} {# -#}
</div> {# -#}
{%- endblock form_row %}

View File

@ -68,7 +68,7 @@ class TranslationDebugCommandTest extends TestCase
/**
* @group legacy
* @expectedDeprecation Storing translations in the "%ssf_translation%s/Resources/translations" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/translations" directory instead.
* @expectedDeprecation Storing templates in the "%ssf_translation%s/Resources/views" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/templates" directory instead.
* @expectedDeprecation Loading Twig templates from the "%ssf_translation%s/Resources/views" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/templates" directory instead.
*/
public function testDebugLegacyDefaultDirectory()
{

View File

@ -385,7 +385,7 @@ EOF;
$fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
if (!$fmt) {
return sprintf('<span class="block trace-file-path">in <a title="%s%3$s"><strong>%s</strong>%s</a></span>', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
return sprintf('<span class="block trace-file-path">in <span title="%s%3$s"><strong>%s</strong>%s</span></span>', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
}
if (\is_string($fmt)) {
@ -401,7 +401,11 @@ EOF;
$link = strtr($fmt[0], ['%f' => $path, '%l' => $line]);
} else {
$link = $fmt->format($path, $line);
try {
$link = $fmt->format($path, $line);
} catch (\Exception $e) {
return sprintf('<span class="block trace-file-path">in <span title="%s%3$s"><strong>%s</strong>%s</span></span>', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
}
}
return sprintf('<span class="block trace-file-path">in <a href="%s" title="Go to source"><strong>%s</string>%s</a></span>', $this->escapeHtml($link), $file, 0 < $line ? ' line '.$line : '');

View File

@ -25,7 +25,7 @@ class FileTypeTest extends BaseTypeTest
protected function getExtensions()
{
$translator = $this->createMock(TranslatorInterface::class);
$translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
$translator->expects($this->any())->method('trans')->willReturnArgument(0);
return array_merge(parent::getExtensions(), [new CoreExtension(null, null, $translator)]);
@ -199,11 +199,12 @@ class FileTypeTest extends BaseTypeTest
*/
public function testFailedFileUploadIsTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage)
{
$requestHandler = new HttpFoundationRequestHandler();
$form = $this->factory
->createBuilder(static::TESTED_TYPE)
->setRequestHandler(new HttpFoundationRequestHandler())
->setRequestHandler($requestHandler)
->getForm();
$form->submit(new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'foo', null, null, $errorCode, true));
$form->submit($this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'foo', $errorCode));
if (UPLOAD_ERR_OK === $errorCode) {
$this->assertTrue($form->isValid());
@ -243,15 +244,16 @@ class FileTypeTest extends BaseTypeTest
*/
public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage)
{
$requestHandler = new HttpFoundationRequestHandler();
$form = $this->factory
->createBuilder(static::TESTED_TYPE, null, [
'multiple' => true,
])
->setRequestHandler(new HttpFoundationRequestHandler())
->setRequestHandler($requestHandler)
->getForm();
$form->submit([
new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'foo', null, null, $errorCode, true),
new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'bar', null, null, $errorCode, true),
$this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'foo', $errorCode),
$this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'bar', $errorCode),
]);
if (UPLOAD_ERR_OK === $errorCode) {
@ -316,15 +318,21 @@ class FileTypeTest extends BaseTypeTest
];
}
private function createUploadedFile(RequestHandlerInterface $requestHandler, $path, $originalName)
private function createUploadedFile(RequestHandlerInterface $requestHandler, $path, $originalName, $errorCode = 0)
{
if ($requestHandler instanceof HttpFoundationRequestHandler) {
return new UploadedFile($path, $originalName, null, null, true);
$class = new \ReflectionClass(UploadedFile::class);
if (5 === $class->getConstructor()->getNumberOfParameters()) {
return new UploadedFile($path, $originalName, null, $errorCode, true);
}
return new UploadedFile($path, $originalName, null, null, $errorCode, true);
}
return [
'name' => $originalName,
'error' => 0,
'error' => $errorCode,
'type' => 'text/plain',
'tmp_name' => $path,
'size' => null,

View File

@ -59,6 +59,12 @@ class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
protected function getFailedUploadedFile($errorCode)
{
$class = new \ReflectionClass(UploadedFile::class);
if (5 === $class->getConstructor()->getNumberOfParameters()) {
return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo', null, $errorCode, true);
}
return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo', null, null, $errorCode, true);
}
}

View File

@ -335,29 +335,33 @@
<target>Dieser Wert sollte gültiges JSON sein.</target>
</trans-unit>
<trans-unit id="87">
<source>This value should be positive.</source>
<target>Dieser Wert sollte positiv sein.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be either positive or zero.</source>
<target>Dieser Wert sollte entweder positiv oder 0 sein.</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be negative.</source>
<target>Dieser Wert sollte negativ sein.</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be either negative or zero.</source>
<target>Dieser Wert sollte entweder negativ oder 0 sein.</target>
</trans-unit>
<trans-unit id="91">
<source>This collection should contain only unique elements.</source>
<target>Diese Sammlung darf keine doppelten Elemente enthalten.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>Diese Zahl sollte positiv sein.</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>Diese Zahl sollte entweder positiv oder 0 sein.</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>Diese Zahl sollte negativ sein.</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>Diese Zahl sollte entweder negativ oder 0 sein.</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>Dieser Wert ist keine gültige Zeitzone.</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>Dieses Passwort ist Teil eines Datenlecks, es darf nicht verwendet werden.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -335,29 +335,33 @@
<target>This value should be valid JSON.</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>
<target>This collection should contain only unique elements.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>This value should be positive.</target>
</trans-unit>
<trans-unit id="88">
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>This value should be either positive or zero.</target>
</trans-unit>
<trans-unit id="89">
<trans-unit id="90">
<source>This value should be negative.</source>
<target>This value should be negative.</target>
</trans-unit>
<trans-unit id="90">
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>This value should be either negative or zero.</target>
</trans-unit>
<trans-unit id="91">
<source>This collection should contain only unique elements.</source>
<target>This collection should contain only unique elements.</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>This value is not a valid timezone.</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>This password has been leaked in a data breach, it must not be used. Please use another password.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -335,25 +335,33 @@
<target>Giá trị này nên đúng định dạng JSON.</target>
</trans-unit>
<trans-unit id="87">
<source>This value should be positive.</source>
<target>Giá trị này có thể thực hiện được.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be either positive or zero.</source>
<target>Giá trị này có thể thực hiện được hoặc bằng không.</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be negative.</source>
<target>Giá trị này nên bị từ chối.</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be either negative or zero.</source>
<target>Giá trị này nên bị từ chối hoặc bằng không.</target>
</trans-unit>
<trans-unit id="91">
<source>This collection should contain only unique elements.</source>
<target>Danh sách này chỉ nên chứa các phần tử khác nhau.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>Giá trị này có thể thực hiện được.</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>Giá trị này có thể thực hiện được hoặc bằng không.</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>Giá trị này nên bị từ chối.</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>Giá trị này nên bị từ chối hoặc bằng không.</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>Giá trị này không phải là múi giờ hợp lệ.</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>Mật khẩu này đã bị rò rỉ dữ liệu, không được sử dụng nữa. Xin vui lòng sử dụng mật khẩu khác.</target>
</trans-unit>
</body>
</file>
</xliff>