Skip to content

Commit

Permalink
getting xml tests going
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Jan 25, 2025
1 parent 4e5ac02 commit 997b746
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion template/tests/versions/types/class.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ public function testCanTranscodeBundleJSON()
$client = $this->_getClient();
$rc = $client->readRaw(
resourceType: <?php echo $versionTypeEnum->getEntityName(); ?>::<?php echo $type->getConstName(false); ?>,
format: <?php echo $clientFormatEnum->getEntityName(); ?>::JSON,
count: 5,
format: <?php echo $clientFormatEnum->getEntityName(); ?>::JSON,
);
if (404 === $rc->getCode()) {
$this->markTestSkipped(sprintf(
Expand All @@ -180,6 +180,36 @@ public function testCanTranscodeBundleJSON()
$this->assertJson($enc);
$this->assertJsonStringEqualsJsonString($rc->getResp(), $enc);
}

public function testCanTranscodeBundleXML()
{
$client = $this->_getClient();
$rc = $client->readRaw(
resourceType: <?php echo $versionTypeEnum->getEntityName(); ?>::<?php echo $type->getConstName(false); ?>,
count: 5,
format: <?php echo $clientFormatEnum->getEntityName(); ?>::XML,
);
if (404 === $rc->getCode()) {
$this->markTestSkipped(sprintf(
'Configured test endpoint "%s" has no resources of type "<?php echo $type->getFHIRName(); ?>"',
$this->_getTestEndpoint(),
));
}
$this->assertIsString($rc->getResp());
$this->assertEquals(200, $rc->getCode(), sprintf('Configured test endpoint "%s" returned non-200 response code', $this->_getTestEndpoint()));
$bundle = <?php echo $bundleType->getClassName(); ?>::xmlUnserialize(
element: $rc->getResp(),
config: $this->_version->getConfig()->getUnserializeConfig(),
);
$entry = $bundle->getEntry();
$this->assertNotCount(0, $entry);
foreach($entry as $ent) {
$resource = $ent->getResource();
$this->assertInstanceOf(<?php echo $type->getclassname(); ?>::class, $resource);
}
$xw = $bundle->xmlSerialize(config: $this->_version->getConfig()->getSerializeConfig());
$this->assertXmlStringEqualsXmlString($rc->getResp(), $xw->outputMemory());
}
<?php endif; ?>
}
<?php return ob_get_clean();

0 comments on commit 997b746

Please sign in to comment.