Skip to content

Commit

Permalink
test: change @context jsons in DocumentationNormalizerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Dassonville committed Oct 8, 2024
1 parent f8dc31e commit 06af67c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 91 deletions.
26 changes: 13 additions & 13 deletions src/Hydra/Serializer/DocumentationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,19 +575,19 @@ private function getContext(string $hydraPrefix = ContextBuilder::HYDRA_PREFIX):
return [
ContextBuilderInterface::HYDRA_CONTEXT,
[
'@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#',
'hydra' => ContextBuilderInterface::HYDRA_NS,
'rdf' => ContextBuilderInterface::RDF_NS,
'rdfs' => ContextBuilderInterface::RDFS_NS,
'xmls' => ContextBuilderInterface::XML_NS,
'owl' => ContextBuilderInterface::OWL_NS,
'schema' => ContextBuilderInterface::SCHEMA_ORG_NS,
'domain' => ['@id' => 'rdfs:domain', '@type' => '@id'],
'range' => ['@id' => 'rdfs:range', '@type' => '@id'],
'subClassOf' => ['@id' => 'rdfs:subClassOf', '@type' => '@id'],
'expects' => ['@id' => $hydraPrefix.'expects', '@type' => '@id'],
'returns' => ['@id' => $hydraPrefix.'returns', '@type' => '@id'],
]
'@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#',
'hydra' => ContextBuilderInterface::HYDRA_NS,
'rdf' => ContextBuilderInterface::RDF_NS,
'rdfs' => ContextBuilderInterface::RDFS_NS,
'xmls' => ContextBuilderInterface::XML_NS,
'owl' => ContextBuilderInterface::OWL_NS,
'schema' => ContextBuilderInterface::SCHEMA_ORG_NS,
'domain' => ['@id' => 'rdfs:domain', '@type' => '@id'],
'range' => ['@id' => 'rdfs:range', '@type' => '@id'],
'subClassOf' => ['@id' => 'rdfs:subClassOf', '@type' => '@id'],
'expects' => ['@id' => $hydraPrefix.'expects', '@type' => '@id'],
'returns' => ['@id' => $hydraPrefix.'returns', '@type' => '@id'],
],
];
}

Expand Down
165 changes: 87 additions & 78 deletions src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,35 @@ private function doTestNormalize($resourceMetadataFactory = null): void

$expected = [
'@context' => [
'@vocab' => '/doc#',
'hydra' => 'http://www.w3.org/ns/hydra/core#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'xmls' => 'http://www.w3.org/2001/XMLSchema#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'schema' => 'https://schema.org/',
'domain' => [
'@id' => 'rdfs:domain',
'@type' => '@id',
],
'range' => [
'@id' => 'rdfs:range',
'@type' => '@id',
],
'subClassOf' => [
'@id' => 'rdfs:subClassOf',
'@type' => '@id',
],
'expects' => [
'@id' => 'hydra:expects',
'@type' => '@id',
],
'returns' => [
'@id' => 'hydra:returns',
'@type' => '@id',
'http://www.w3.org/ns/hydra/context.jsonld',
[
'@vocab' => '/doc#',
'hydra' => 'http://www.w3.org/ns/hydra/core#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'xmls' => 'http://www.w3.org/2001/XMLSchema#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'schema' => 'https://schema.org/',
'domain' => [
'@id' => 'rdfs:domain',
'@type' => '@id',
],
'range' => [
'@id' => 'rdfs:range',
'@type' => '@id',
],
'subClassOf' => [
'@id' => 'rdfs:subClassOf',
'@type' => '@id',
],
'expects' => [
'@id' => 'hydra:expects',
'@type' => '@id',
],
'returns' => [
'@id' => 'hydra:returns',
'@type' => '@id',
],
],
],
'@id' => '/doc',
Expand Down Expand Up @@ -411,32 +414,35 @@ public function testNormalizeInputOutputClass(): void

$expected = [
'@context' => [
'@vocab' => '/doc#',
'hydra' => 'http://www.w3.org/ns/hydra/core#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'xmls' => 'http://www.w3.org/2001/XMLSchema#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'schema' => 'https://schema.org/',
'domain' => [
'@id' => 'rdfs:domain',
'@type' => '@id',
],
'range' => [
'@id' => 'rdfs:range',
'@type' => '@id',
],
'subClassOf' => [
'@id' => 'rdfs:subClassOf',
'@type' => '@id',
],
'expects' => [
'@id' => 'hydra:expects',
'@type' => '@id',
],
'returns' => [
'@id' => 'hydra:returns',
'@type' => '@id',
'http://www.w3.org/ns/hydra/context.jsonld',
[
'@vocab' => '/doc#',
'hydra' => 'http://www.w3.org/ns/hydra/core#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'xmls' => 'http://www.w3.org/2001/XMLSchema#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'schema' => 'https://schema.org/',
'domain' => [
'@id' => 'rdfs:domain',
'@type' => '@id',
],
'range' => [
'@id' => 'rdfs:range',
'@type' => '@id',
],
'subClassOf' => [
'@id' => 'rdfs:subClassOf',
'@type' => '@id',
],
'expects' => [
'@id' => 'hydra:expects',
'@type' => '@id',
],
'returns' => [
'@id' => 'hydra:returns',
'@type' => '@id',
],
],
],
'@id' => '/doc',
Expand Down Expand Up @@ -776,32 +782,35 @@ public function testNormalizeWithoutPrefix(): void

$expected = [
'@context' => [
'@vocab' => '/doc#',
'hydra' => 'http://www.w3.org/ns/hydra/core#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'xmls' => 'http://www.w3.org/2001/XMLSchema#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'schema' => 'https://schema.org/',
'domain' => [
'@id' => 'rdfs:domain',
'@type' => '@id',
],
'range' => [
'@id' => 'rdfs:range',
'@type' => '@id',
],
'subClassOf' => [
'@id' => 'rdfs:subClassOf',
'@type' => '@id',
],
'expects' => [
'@id' => 'expects',
'@type' => '@id',
],
'returns' => [
'@id' => 'returns',
'@type' => '@id',
'http://www.w3.org/ns/hydra/context.jsonld',
[
'@vocab' => '/doc#',
'hydra' => 'http://www.w3.org/ns/hydra/core#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'xmls' => 'http://www.w3.org/2001/XMLSchema#',
'owl' => 'http://www.w3.org/2002/07/owl#',
'schema' => 'https://schema.org/',
'domain' => [
'@id' => 'rdfs:domain',
'@type' => '@id',
],
'range' => [
'@id' => 'rdfs:range',
'@type' => '@id',
],
'subClassOf' => [
'@id' => 'rdfs:subClassOf',
'@type' => '@id',
],
'expects' => [
'@id' => 'expects',
'@type' => '@id',
],
'returns' => [
'@id' => 'returns',
'@type' => '@id',
],
],
],
'@id' => '/doc',
Expand Down

0 comments on commit 06af67c

Please sign in to comment.