-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add CDATA_WRAPPING_NAME_PATTERN support to XmlEncoder #60355
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
base: 7.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,6 +568,23 @@ public function testDecodeXMLWithProcessInstruction() | |
$this->assertEquals(get_object_vars($obj), $this->encoder->decode($source, 'xml')); | ||
} | ||
|
||
public function testCDataNamePattern() | ||
{ | ||
$expected = <<<'XML' | ||
<?xml version="1.0"?> | ||
<response><person><firstname><![CDATA[Benjamin]]></firstname><lastname><![CDATA[Alexandre]]></lastname><other><![CDATA[data]]></other></person><person><firstname><![CDATA[Damien]]></firstname><lastname><![CDATA[Clay]]></lastname><other><![CDATA[data]]></other></person></response> | ||
|
||
XML; | ||
$source = ['person' => [ | ||
['firstname' => 'Benjamin', 'lastname' => 'Alexandre', 'other' => 'data'], | ||
['firstname' => 'Damien', 'lastname' => 'Clay', 'other' => 'data'], | ||
]]; | ||
|
||
$this->assertEquals($expected, $this->encoder->encode($source, 'xml',[ | ||
XmlEncoder::CDATA_WRAPPING_NAME_PATTERN => '(firstname|lastname|)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the test, I did not expected to see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes thats right. I will fix it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using parenthesis as regex delimiter is quite uncommon. People reading the tests could think that we expect a partial pattern where we add the delimiter ourselves. I suggest changing the delimiters being used (and I also suggest using an anchored regex in that test) |
||
])); | ||
} | ||
|
||
public function testDecodeIgnoreWhiteSpace() | ||
{ | ||
$source = <<<'XML' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.