Skip to content

Commit e4f0fd6

Browse files
committed
Add basic RDFSource test
1 parent 8d1e983 commit e4f0fd6

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

src/Model/RDFSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function respond(Application $app, Request $request, array $options = arr
3232
}
3333
}
3434

35-
if ($this->canStream()) {
35+
if ($this->canStream($responseFormat)) {
3636
$digest = $this->wantDigest($request->headers->get('want-digest'));
3737
if ($digest) {
3838
$res->headers->set('Digest', $digest);

test/Model/RDFSourceTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)