Skip to content

fix tests #30989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix tests
  • Loading branch information
xabbuh committed Apr 7, 2019
commit 27df966705d89c76c47d78c326cc0c78acb270c6
Original file line number Diff line number Diff line change
Expand Up @@ -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) }} {# -#}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably just a mistake when resolving conflicts while merging up

{{ form_errors(form) }} {# -#}
</div> {# -#}
{%- endblock form_row %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testDebugDefaultDirectory()
/**
* @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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

messages were clarified in #30952

*/
public function testDebugLegacyDefaultDirectory()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,12 @@ public function requestHandlerProvider()
*/
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());
Expand Down Expand Up @@ -243,15 +244,16 @@ public function testFailedFileUploadIsTurnedIntoFormErrorUsingNativeRequestHandl
*/
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) {
Expand Down Expand Up @@ -316,15 +318,21 @@ public function uploadFileErrorCodes()
];
}

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ protected function getInvalidFile()

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);
}
}