|
5 | 5 | use GuzzleHttp\Promise\Promise;
|
6 | 6 | use function GuzzleHttp\Promise\promise_for;
|
7 | 7 | use Markup\Contentful\AssetInterface;
|
| 8 | +use Markup\Contentful\ContentTypeInterface; |
8 | 9 | use Markup\Contentful\Entry;
|
9 | 10 | use Markup\Contentful\EntryInterface;
|
10 | 11 | use Markup\Contentful\Exception\LinkUnresolvableException;
|
@@ -115,4 +116,29 @@ public function testUnresolvedSingleLinkEmitsNull()
|
115 | 116 | $entry->setResolveLinkFunction($callback);
|
116 | 117 | $this->assertNull($entry['asset']);
|
117 | 118 | }
|
| 119 | + |
| 120 | + public function testGetResolvedContentType() |
| 121 | + { |
| 122 | + $contentType = m::mock(ContentTypeInterface::class); |
| 123 | + $this->metadata |
| 124 | + ->shouldReceive('getContentType') |
| 125 | + ->andReturn($contentType); |
| 126 | + $this->assertSame($contentType, $this->entry->getContentType()); |
| 127 | + } |
| 128 | + |
| 129 | + public function testGetUnresolvedContentType() |
| 130 | + { |
| 131 | + $link = m::mock(Link::class); |
| 132 | + $this->metadata |
| 133 | + ->shouldReceive('getContentType') |
| 134 | + ->andReturn($link); |
| 135 | + $contentType = m::mock(ContentTypeInterface::class); |
| 136 | + $callback = function ($link) use ($contentType) { |
| 137 | + $this->assertInstanceOf(Link::class, $link); |
| 138 | + |
| 139 | + return promise_for($contentType); |
| 140 | + }; |
| 141 | + $this->entry->setResolveLinkFunction($callback); |
| 142 | + $this->assertSame($contentType, $this->entry->getContentType()); |
| 143 | + } |
118 | 144 | }
|
0 commit comments