@@ -32,22 +32,41 @@ public function setUp()
3232 */
3333 public function testGetRDFSource ()
3434 {
35- $ expected_charset = "text/turtle; charset=UTF-8 " ;
36- $ expected_links = [
35+ $ expected_links = [
3736 "< " . Resource::LDP_NS . "Resource>; rel= \"type \"" ,
3837 "< " . Resource::LDP_NS . "RDFSource>; rel= \"type \""
3938 ];
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 );
39+ $ expected_vary = "Accept " ;
40+ $ request_mime = "text/turtle " ;
4441
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 " );
42+ $ this ->client ->request ('GET ' , "/nobel_914.ttl " , [], [], ['HTTP_ACCEPT ' => $ request_mime ]);
43+ $ this ->assertEquals (200 , $ this ->client ->getResponse ()->getStatusCode (), "GET should be allowed. " );
44+ $ response = $ this ->client ->getResponse ();
45+ $ charset = $ response ->getCharset ();
46+ $ expected_mime = "{$ request_mime }; charset= {$ charset }" ;
4747
4848 $ this ->assertTrue ($ response ->headers ->has ('Link ' ), "Missing Link header " );
4949 $ this ->assertEquals ($ expected_links , $ response ->headers ->get ("Link " , null , false ), "Link headers incorrect. " );
5050
51+ $ this ->assertTrue ($ response ->headers ->has ('Vary ' ), "Missing Vary header " );
52+ $ this ->assertEquals ($ expected_vary , $ response ->headers ->get ('Vary ' ), "Vary headers incorrect. " );
53+
54+ $ this ->assertTrue ($ response ->headers ->has ("Content-Type " ), "Missing Content-Type header " );
55+ $ this ->assertEquals ($ expected_mime , $ response ->headers ->get ('Content-Type ' ), "Content-Type header incorrect " );
56+
5157 $ this ->assertTrue ($ response ->headers ->has ("etag " ), "Missing Etag header. " );
58+ $ etag = $ response ->headers ->get ('etag ' );
59+
60+ $ this ->client ->request ('GET ' , "/nobel_914.ttl " , [], [], ['HTTP_ACCEPT ' => $ expected_mime ]);
61+ $ this ->assertEquals (200 , $ this ->client ->getResponse ()->getStatusCode (), "GET should be allowed a second time. " );
62+ $ this ->assertTrue ($ this ->client ->getResponse ()->headers ->has ("etag " ), "Missing Etag header. " );
63+ $ this ->assertEquals ($ etag , $ this ->client ->getResponse ()->headers ->get ('etag ' ), "Etags don't match. " );
64+
65+ $ headers = [
66+ 'HTTP_ACCEPT ' => $ expected_mime ,
67+ 'HTTP_IF_NONE_MATCH ' => "{$ etag }"
68+ ];
69+ $ this ->client ->request ('GET ' , "/nobel_914.ttl " , [], [], $ headers );
70+ $ this ->assertEquals (304 , $ this ->client ->getResponse ()->getStatusCode (), "Conditional GET should return a 304 " );
5271 }
5372}
0 commit comments