|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Trellis\StaticLdp\Model; |
| 4 | + |
| 5 | +use Trellis\StaticLdp\StaticLdpTestBase; |
| 6 | + |
| 7 | +/** |
| 8 | + * Unit Test of RDFSource class. |
| 9 | + * |
| 10 | + * @coversDefaultClass \Trellis\StaticLdp\Model\RDFSource |
| 11 | + * @group unittest |
| 12 | + */ |
| 13 | +class RDFSourceTest extends StaticLdpTestBase |
| 14 | +{ |
| 15 | + |
| 16 | + /** |
| 17 | + * @var \Symfony\Component\BrowserKit\Client |
| 18 | + */ |
| 19 | + protected $client; |
| 20 | + |
| 21 | + /** |
| 22 | + * {@inheritdoc} |
| 23 | + */ |
| 24 | + public function setUp() |
| 25 | + { |
| 26 | + parent::setUp(); |
| 27 | + $this->client = $this->createClient(); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Test GET a RDFSource |
| 32 | + */ |
| 33 | + public function testGetRDFSource() |
| 34 | + { |
| 35 | + $expected_charset = "text/turtle; charset=UTF-8"; |
| 36 | + $expected_links = [ |
| 37 | + "<" . Resource::LDP_NS . "Resource>; rel=\"type\"", |
| 38 | + "<" . Resource::LDP_NS . "RDFSource>; rel=\"type\"" |
| 39 | + ]; |
| 40 | + $crawler = $this->client->request('GET', "/nobel_914.ttl", [], [], ["HTTP_ACCEPT" => "text/turtle"]); |
| 41 | + $response = $this->client->getResponse(); |
| 42 | + |
| 43 | + $this->assertEquals($response->getStatusCode(), 200); |
| 44 | + |
| 45 | + $this->assertTrue($response->headers->has("Content-Type"), "Missing Content-Type header"); |
| 46 | + $this->assertEquals($expected_charset, $response->headers->get('Content-Type'), "Content-Type incorrect"); |
| 47 | + |
| 48 | + $this->assertTrue($response->headers->has('Link'), "Missing Link header"); |
| 49 | + $this->assertEquals($expected_links, $response->headers->get("Link", null, false), "Link headers incorrect."); |
| 50 | + |
| 51 | + $this->assertTrue($response->headers->has("etag"), "Missing Etag header."); |
| 52 | + } |
| 53 | +} |
0 commit comments