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

[Serializer] Xml encoder throws exception for valid data#21671

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
gr1ev0us wants to merge3 commits intosymfony:2.7fromgr1ev0us:ticket_21617

Conversation

@gr1ev0us
Copy link
Contributor

@gr1ev0usgr1ev0us commentedFeb 19, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#21617
LicenseMIT
Doc PRNone

#21617 Xml encoder throws exception for valid data

  • add tests for bool and object encoding
  • fix encoding for object in array and field

* add tests for bool and object encoding* fix encoding for object in array and field
*/
private$encoder;

/**
Copy link
Member

Choose a reason for hiding this comment

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

This comment is useless (the IDE will be able to infer the type using the default value).

gr1ev0us reacted with thumbs up emoji
}

/**
* @test
Copy link
Member

Choose a reason for hiding this comment

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

This block is useless (same below).

gr1ev0us reacted with thumbs up emoji
*/
publicfunctiontestEncodeXmlWithBoolValue()
{
$expectedXml ='<?xml version="1.0"?>
Copy link
Member

Choose a reason for hiding this comment

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

You may use the heredoc syntax (the IDE will be able to highlight the snippet). (Just suggestion, not mandatory).

gr1ev0us reacted with thumbs up emoji
<response><foo>1</foo><bar>0</bar></response>
';

$actualXml =$this->encoder->encode(array('foo' =>true,'bar' =>false),'xml');
Copy link
Member

Choose a reason for hiding this comment

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

I don't get why this is expected? IMO it should bearray('foo' => '1', 'bar' => '0') unless explicitly defined as bool in a XML schema.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This is an actual behavior of XmlEncode, to cast bool to int. I am not sure that i should fix this non explicit behaviour, so i am just cover that with test.


namespaceSymfony\Component\Serializer\Tests\Encoder;

useDateTime;
Copy link
Member

Choose a reason for hiding this comment

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

For classes in the global namespace, we don't import them (use\DateTime directly).

gr1ev0us reacted with thumbs up emoji
@nicolas-grekasnicolas-grekas changed the titleIssue-21617 Xml encoder throws exception for valid data[Serializer] Xml encoder throws exception for valid dataFeb 25, 2017
namespaceSymfony\Component\Serializer\Tests\Encoder;

usePHPUnit\Framework\TestCase;
useSymfony\Component\Serializer\Tests\Fixtures\Dummy;

Choose a reason for hiding this comment

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

please revert any change related to ordering: our policy is to addnew lines in alpha order, but keep old ones as is - to help for merges between branches.

gr1ev0us reacted with thumbs up emoji
@nicolas-grekasnicolas-grekas added this to the2.7 milestoneFeb 25, 2017
@fabpot
Copy link
Member

@dunglas Is this one ok for you?

@dunglas
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@gr1ev0us.

gr1ev0us reacted with thumbs up emoji

fabpot added a commit that referenced this pull requestMar 5, 2017
…gr1ev0us)This PR was squashed before being merged into the 2.7 branch (closes#21671).Discussion----------[Serializer] Xml encoder throws exception for valid data| Q             | A| ------------- | ---| Branch?       |  2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#21617| License       | MIT| Doc PR        | None#21617  Xml encoder throws exception for valid data- add tests for bool and object encoding- fix encoding for object in array and fieldCommits-------5c2d4c6 [Serializer] Xml encoder throws exception for valid data
@fabpotfabpot closed thisMar 5, 2017
This was referencedMar 6, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@gr1ev0us@fabpot@dunglas@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp