public function testEncodeStructWithExtension(): void
{ $this->
registerDefinition(ExtendableDefinition::
class, ExtendedDefinition::
class);
$extendableDefinition =
new ExtendableDefinition();
$extendableDefinition->
addExtension(new AssociationExtension());
$extendableDefinition->
addExtension(new ScalarRuntimeExtension());
$extendableDefinition->
compile($this->
getContainer()->
get(DefinitionInstanceRegistry::
class));
$fixture =
new TestBasicWithExtension();
$encoder =
$this->
getContainer()->
get(JsonApiEncoder::
class);
$actual =
$encoder->
encode(new Criteria(),
$extendableDefinition,
$fixture->
getInput(), SerializationFixture::SALES_CHANNEL_API_BASE_URL
);
// check that empty "links" object is an object and not array: https://jsonapi.org/format/#document-links
static::
assertStringNotContainsString('"links":[]',
$actual);
// TODO: WTF? Why does it now have a self link
// static::assertStringContainsString('"links":{}', $actual);
$this->
assertValues($fixture->
getSalesChannelJsonApiFixtures(),
json_decode((string) $actual, true, 512, \JSON_THROW_ON_ERROR
));
}