server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php
changeset 168 17f10b56c079
parent 143 023b6d467566
child 277 bd4bc1db4f40
--- a/server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php	Thu Jun 02 18:16:17 2016 +0200
+++ b/server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php	Thu Jun 02 18:24:19 2016 +0200
@@ -6,6 +6,8 @@
 use CorpusParole\Repositories\DocumentRepository;
 use CorpusParole\Repositories\RdfDocumentRepository;
 use CorpusParole\Models\Document;
+use CorpusParole\Models\DocumentResult;
+
 
 use SebastianBergmann\Diff\Differ;
 
@@ -135,7 +137,7 @@
 
         $resDoc = $docList[0];
 
-        $this->assertInstanceOf(Document::class, $resDoc, "Res doc must be a Document");
+        $this->assertInstanceOf(DocumentResult::class, $resDoc, "Res doc must be a Document");
         $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $resDoc->getId(), "id must be crdo...");
         $this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...');
         $this->assertNotNull($resDoc->getGraph(), 'Graph must not be null');
@@ -156,6 +158,21 @@
         $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph));
     }
 
+    public function testGetShort() {
+
+        $expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738';
+        $returnedGraph = new EasyRdf\Graph($expectedId, sprintf(DocumentRepositoryIntegrationTest::TEST_DOC,config('corpusparole.corpus_doc_id_base_uri')));
+
+        $res = $this->documentRepository->get('crdo-ALA_738', true);
+
+        $this->assertInstanceOf(DocumentResult::class, $res, "Result must be of type DocumentResult");
+        $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' );
+        $this->assertNotNull($res->getGraph(), "Graph shoul not be null");
+        $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738",$res->getGraph()->getUri(), "uri of graph must be ".config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738");
+        $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph));
+    }
+
+
     public function testSave() {
 
         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", $this->graph);