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

fix: Fix 'Exception: String could not be parsed as XML' in xml's consumer test #624

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading