Skip to content

Commit

Permalink
Add a new test
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 10, 2020
1 parent 2fffa84 commit f9c985b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/JsonLd/ContextBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,22 @@ public function testAnonymousResourceContextWithApiResource()

$this->assertEquals($expected, $contextBuilder->getAnonymousResourceContext($output, ['iri' => '/dummies', 'name' => 'Dummy', 'api_resource' => new Dummy()]));
}

public function testAnonymousResourceContextWithApiResourceHavingContext()
{
$output = new OutputDto();
$this->propertyNameCollectionFactoryProphecy->create(OutputDto::class)->willReturn(new PropertyNameCollection(['dummyPropertyA']));
$this->propertyMetadataFactoryProphecy->create(OutputDto::class, 'dummyPropertyA')->willReturn(new PropertyMetadata(new Type(Type::BUILTIN_TYPE_STRING), 'Dummy property A', true, true, true, true, false, false, null, null, []));

$this->resourceMetadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadata('Dummy'));

$contextBuilder = new ContextBuilder($this->resourceNameCollectionFactoryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $this->propertyNameCollectionFactoryProphecy->reveal(), $this->propertyMetadataFactoryProphecy->reveal(), $this->urlGeneratorProphecy->reveal());

$expected = [
'@id' => '/dummies',
'@type' => 'Dummy',
];

$this->assertEquals($expected, $contextBuilder->getAnonymousResourceContext($output, ['iri' => '/dummies', 'name' => 'Dummy', 'api_resource' => new Dummy(), 'has_context' => true]));
}
}

0 comments on commit f9c985b

Please sign in to comment.