Skip to content

Commit

Permalink
Merge pull request #624 from tienvx/fix-string-could-not-be-parsed-as…
Browse files Browse the repository at this point in the history
…-xml

fix: Fix 'Exception: String could not be parsed as XML' in xml's consumer test
  • Loading branch information
tienvx committed Aug 30, 2024
2 parents 61bc2b3 + 68e4cc4 commit 55e5d60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions example/xml/consumer/tests/Service/HttpClientServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace XmlConsumer\Tests\Service;

use PhpPact\Consumer\Matcher\Matcher;
use PhpPact\Consumer\Model\Body\Text;
use PhpPact\Xml\XmlBuilder;
use XmlConsumer\Service\HttpClientService;
use PhpPact\Consumer\InteractionBuilder;
Expand Down Expand Up @@ -83,9 +84,7 @@ public function testGetMovies()
$response
->setStatus(200)
->addHeader('Content-Type', $matcher->regex('application/xml', 'application\/.*xml'))
->setBody(
json_encode($xmlBuilder)
);
->setBody(new Text(json_encode($xmlBuilder), 'application/xml'));

$config = new MockServerConfig();
$config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class ResponseDriver extends AbstractInteractionPartDriver implements ResponseDr
{
public function registerResponse(Interaction $interaction): void
{
// @todo Fix 'Exception: String could not be parsed as XML' in xml's consumer test
// when calling `withBody` before `withHeaders`
$this->withHeaders($interaction, InteractionPart::RESPONSE);
$this->withBody($interaction, InteractionPart::RESPONSE);
$this->withHeaders($interaction, InteractionPart::RESPONSE);
$this->withResponse($interaction);
}

Expand Down

0 comments on commit 55e5d60

Please sign in to comment.