8000 minor #30989 fix tests (xabbuh) · symfony/symfony@5b8a68d · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b8a68d

Browse files
committed
minor #30989 fix tests (xabbuh)
This PR was merged into the 4.2 branch. Discussion ---------- fix tests | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 27df966 fix tests
2 parents 397e4b8 + 27df966 commit 5b8a68d

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
115115
{{- form_label(form) }} {# -#}
116116
{{ form_widget(form, widget_attr) }} {# -#}
117-
{{ form_widget(form) }} {# -#}
118117
{{ form_errors(form) }} {# -#}
119118
</div> {# -#}
120119
{%- endblock form_row %}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testDebugDefaultDirectory()
6868
/**
6969
* @group legacy
7070
* @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.
71-
* @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.
71+
* @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.
7272
*/
7373
public function testDebugLegacyDefaultDirectory()
7474
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ public function requestHandlerProvider()
199199
*/
200200
public function testFailedFileUploadIsTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage)
201201
{
202+
$requestHandler = new HttpFoundationRequestHandler();
202203
$form = $this->factory
203204
->createBuilder(static::TESTED_TYPE)
204-
->setRequestHandler(new HttpFoundationRequestHandler())
205+
->setRequestHandler($requestHandler)
205206
->getForm();
206-
$form->submit(new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'foo', null, null, $errorCode, true));
207+
$form->submit($this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'foo', $errorCode));
207208

208209
if (UPLOAD_ERR_OK === $errorCode) {
209210
$this->assertTrue($form->isValid());
@@ -243,15 +244,16 @@ public function testFailedFileUploadIsTurnedIntoFormErrorUsingNativeRequestHandl
243244
*/
244245
public function testMultipleSubmittedFailedFileUploadsAreTurnedIntoFormErrorUsingHttpFoundationRequestHandler($errorCode, $expectedErrorMessage)
245246
{
247+
$requestHandler = new HttpFoundationRequestHandler();
246248
$form = $this->factory
247249
->createBuilder(static::TESTED_TYPE, null, [
248250
'multiple' => true,
249251
])
250-
->setRequestHandler(new HttpFoundationRequestHandler())
252+
->setRequestHandler($requestHandler)
251253
->getForm();
252254
$form->submit([
253-
new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'foo', null, null, $errorCode, true),
254-
new UploadedFile(__DIR__.'/../../../Fixtures/foo', 'bar', null, null, $errorCode, true),
255+
$this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'foo', $errorCode),
256+
$this->createUploadedFile($requestHandler, __DIR__.'/../../../Fixtures/foo', 'bar', $errorCode),
255257
]);
256258

257259
if (UPLOAD_ERR_OK === $errorCode) {
@@ -316,15 +318,21 @@ public function uploadFileErrorCodes()
316318
];
317319
}
318320

319-
private function createUploadedFile(RequestHandlerInterface $requestHandler, $path, $originalName)
321+
private function createUploadedFile(RequestHandlerInterface $requestHandler, $path, $originalName, $errorCode = 0)
320322
{
321323
if ($requestHandler instanceof HttpFoundationRequestHandler) {
322-
return new UploadedFile($path, $originalName, null, null, true);
324+
$class = new \ReflectionClass(UploadedFile::class);
325+
326+
if (5 === $class->getConstructor()->getNumberOfParameters()) {
327+
return new UploadedFile($path, $originalName, null, $errorCode, true);
328+
}
329+
330+
return new UploadedFile($path, $originalName, null, null, $errorCode, true);
323331
}
324332

325333
return [
326334
'name' => $originalName,
327-
'error' => 0,
335+
'error' => $errorCode,
328336
'type' => 'text/plain',
329337
'tmp_name' => $path,
330338
'size' => null,

src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ protected function getInvalidFile()
5959

6060
protected function getFailedUploadedFile($errorCode)
6161
{
62+
$class = new \ReflectionClass(UploadedFile::class);
63+
64+
if (5 === $class->getConstructor()->getNumberOfParameters()) {
65+
return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo', null, $errorCode, true);
66+
}
67+
6268
return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo', null, null, $errorCode, true);
6369
}
6470
}

0 commit comments

Comments
 (0)
0