Skip to content
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

comment tag is missing #28

Open
aliaswpeu opened this issue Jun 29, 2024 · 3 comments
Open

comment tag is missing #28

aliaswpeu opened this issue Jun 29, 2024 · 3 comments

Comments

@aliaswpeu
Copy link

aliaswpeu commented Jun 29, 2024

Hello, when using like this, comment tag is not rendered:

$order_body = XmlWriter::make()
            ->setXmlStandalone(true)
            ->write('orders', [
                'order' => [
                    'cod' => '123',
                    'comment' => 'test comment',
                ],

            ]);
"""
<?xml version="1.0" encoding="utf-8"?>\n
<orders>\n
  <order>\n
    <cod>123</cod>\n
    test comment\n
  </order>\n
</orders>\n
"""

Should be:

"""
<?xml version="1.0" encoding="utf-8"?>\n
<orders>\n
  <order>\n
    <cod>123</cod>\n
    <comment>test comment</comment>\n
  </order>\n
</orders>\n
"""
@Sammyjo20
Copy link
Member

This is a very very strange one, I wrote a test to replicate this issue and the XML string that XML Wrangler created looked correct, however when I tried to add an assertion, PEST was magically removing the <comment> tag.

Screenshot 2024-08-03 at 14 42 52

I managed to "fix" the test by putting the expected XML into a variable instead of directly referencing it inside of the toBe expectation.

I don't think there is a bug with XML Wrangler here, as it did produce the expected outcome, but I would check your test suite. Do you have any more information you could share?

@aliaswpeu
Copy link
Author

I was just dumping my output to terminal to see if it is correct.
While I was searching why it happened, if I remember correctly, it was something in veewee/xml package. But I did not manage to fix it. For now, just skipping the comment section in output.

@Sammyjo20
Copy link
Member

I believe the writer uses spatie/array-to-xml and veewee/xml is solely used for reading. Still a very strange issue, because my direct output showed it looked fine, but PEST had the wrong output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants