Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

finish #13598#18047

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
xabbuh wants to merge2 commits intosymfony:2.3fromxabbuh:pr-13598
Closed

finish #13598#18047

xabbuh wants to merge2 commits intosymfony:2.3fromxabbuh:pr-13598

Conversation

@xabbuh
Copy link
Member

QA
Branch2.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#13598
LicenseMIT
Doc PR

… it throws a TransformationFailedException with message: 'Expected a string.'.
@xabbuh
Copy link
MemberAuthor

@HeahDude
Copy link
Contributor

The tests are still skipped, even with#18019 :(

@xabbuh
Copy link
MemberAuthor

At least, on AppVeyor they are executed and pass.

@HeahDude
Copy link
Contributor

Great!Do they fail without the fix too ? never mind, just read your comment in the previous PR.

@xabbuh
Copy link
MemberAuthor

@xabbuhxabbuhforce-pushed thepr-13598 branch 2 times, most recently from3006020 toaa5e45bCompareMarch 7, 2016 13:54

publicfunctiontestSubmitNullWithEmptyDataTrueWhenNested()
{
$form =$this->factory->create('form')
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the tests pass (before the change) if this is not nested? If not, I'd simplify this test.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Neither this one nortestSubmitNullWithEmptyData(which is the same without nesting) do pass without the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, actually@webmozart is right.

You can remove "WhenNested" is the method name and refractor this to:

$form =$this->factory->create('checkbox',null,array('empty_data' =>true,             ));$form->submit(null);$this->assertTrue($form->getData());$this->assertSame('1',$form->getViewData());

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Oh okay, got it now what you were talking about. I changed theCheckboxType tests to not use nested forms and removed the nested test from theIntegerTypeTest where it also wasn't necessary.

@HeahDude
Copy link
Contributor

Also, I confirm I still cannot close#17822 in favor of this one. It remains a singular case.

@HeahDude
Copy link
Contributor

👍

Status: Reviewed

publicfunctiontestSubmitNullWithEmptyDataTrue()
{
$form =$this->factory->create('checkbox',null,array(
'empty_data' =>true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, this code is invalid.empty_data expects data in view format, not in model format. The view format depends on the transformer that is used.

Imagine the field is configured with the following transformer

true <--->'yes'false <---> 'no'

Then this code will fail. Theempty_data valuetrue will be cast to the string'1'. Consequently, the transformer fails, since it doesn't know how to reverse transform'1'.

The correct test would be:

$form =$this->factory->create('checkbox',null,array('empty_data' =>'1',));

I understand this is not very straight-forward nor intuitive, but we can't change that for the moment.

I believe that the use case that motivated this change was actually using theempty_data incorrectly, by passing data in model instead of view format (ping@guilhermeblanco).

Copy link
Contributor

Choose a reason for hiding this comment

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

But it's valid with default settings, right ?

In that test$this->assertSame('1', $viewData) would pass.

@guilhermeblanco
Copy link
Contributor

@xabbuh@webmozart my case was explicitly with integer types, not checkboxes (which are boolean values).

@HeahDude
Copy link
Contributor

@guilhermeblanco Fortunately your fix solves both :) Thanks.

@webmozart
Copy link
Contributor

@guilhermeblanco Did you pass integers or strings (integer strings) toempty_data?

@webmozart
Copy link
Contributor

@xabbuh
Copy link
MemberAuthor

I guess we can close here. Changing the test to use the string1 instead of the integer makes the test pass even without the fix.

Thanks for raising the issue on the docs repo@webmozart. This is indeed something that we have to improve (I didn't know that before).

@HeahDude
Copy link
Contributor

Agreed, I guess we all learned something with this one.

@xabbuh I could deal with insymfony/symfony-docs#6265, what do you think ?

@xabbuh
Copy link
MemberAuthor

@HeahDude 👍

@guilhermeblanco
Copy link
Contributor

OMG... Using string as workaround was detailed in the original ticket that it worked. However, that's not a solution. If you declare an integer field, you expect an integer back, not a string.

@xabbuh
Copy link
MemberAuthor

@guilhermeblanco Sorry for the inconvenience. Though it turns out that using a string is not a workaround but the right solution as this is how the view data for the integer type look like.

@webmozart
Copy link
Contributor

@guilhermeblanco I agree with you. Unfortunately we can't change that for the moment due to BC implications.

@xabbuhxabbuh deleted the pr-13598 branchMarch 14, 2016 10:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@xabbuh@HeahDude@guilhermeblanco@webmozart@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp