fix tests

This commit is contained in:
Christian Flothmann 2019-04-07 19:56:26 +02:00
parent 393c6b390c
commit 27df966705
4 changed files with 23 additions and 10 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 %}"> <div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
{{- form_label(form) }} {# -#} {{- form_label(form) }} {# -#}
{{ form_widget(form, widget_attr) }} {# -#} {{ form_widget(form, widget_attr) }} {# -#}
{{ form_widget(form) }} {# -#}
{{ form_errors(form) }} {# -#} {{ form_errors(form) }} {# -#}
</div> {# -#} </div> {# -#}
{%- endblock form_row %} {%- endblock form_row %}

View File

@ -68,7 +68,7 @@ class TranslationDebugCommandTest extends TestCase
/** /**
* @group legacy * @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 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() public function testDebugLegacyDefaultDirectory()
{ {

View File

@ -199,11 +199,12 @@ class FileTypeTest extends BaseTypeTest
*/ */
public function testFailedFileUploadIsTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage) public function testFailedFileUploadIsTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage)
{ {
$requestHandler = new HttpFoundationRequestHandler();
$form = $this->factory $form = $this->factory
->createBuilder(static::TESTED_TYPE) ->createBuilder(static::TESTED_TYPE)
->setRequestHandler(new HttpFoundationRequestHandler()) ->setRequestHandler($requestHandler)
->getForm(); ->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) { if (UPLOAD_ERR_OK === $errorCode) {
$this->assertTrue($form->isValid()); $this->assertTrue($form->isValid());
@ -243,15 +244,16 @@ class FileTypeTest extends BaseTypeTest
*/ */
public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage) public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage)
{ {
$requestHandler = new HttpFoundationRequestHandler();
$form = $this->factory $form = $this->factory
->createBuilder(static::TESTED_TYPE, null, [ ->createBuilder(static::TESTED_TYPE, null, [
'multiple' => true, 'multiple' => true,
]) ])
->setRequestHandler(new HttpFoundationRequestHandler()) ->setRequestHandler($requestHandler)
->getForm(); ->getForm();
$form->submit([ $form->submit([
new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'foo', null, null, $errorCode, true), $this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'foo', $errorCode),
new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'bar', null, null, $errorCode, true), $this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'bar', $errorCode),
]); ]);
if (UPLOAD_ERR_OK === $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) { 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 [ return [
'name' => $originalName, 'name' => $originalName,
'error' => 0, 'error' => $errorCode,
'type' => 'text/plain', 'type' => 'text/plain',
'tmp_name' => $path, 'tmp_name' => $path,
'size' => null, 'size' => null,

View File

@ -59,6 +59,12 @@ class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
protected function getFailedUploadedFile($errorCode) 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); return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo', null, null, $errorCode, true);
} }
} }