4 use Illuminate\Support\Facades\Config; |
4 use Illuminate\Support\Facades\Config; |
5 |
5 |
6 use CorpusParole\Repositories\DocumentRepository; |
6 use CorpusParole\Repositories\DocumentRepository; |
7 use CorpusParole\Repositories\RdfDocumentRepository; |
7 use CorpusParole\Repositories\RdfDocumentRepository; |
8 use CorpusParole\Models\Document; |
8 use CorpusParole\Models\Document; |
|
9 use CorpusParole\Models\DocumentResult; |
|
10 |
9 |
11 |
10 use SebastianBergmann\Diff\Differ; |
12 use SebastianBergmann\Diff\Differ; |
11 |
13 |
12 use GuzzleHttp\Client; |
14 use GuzzleHttp\Client; |
13 |
15 |
133 $docList = $this->documentRepository->all(); |
135 $docList = $this->documentRepository->all(); |
134 $this->assertCount(1, $docList, "Should have one element"); |
136 $this->assertCount(1, $docList, "Should have one element"); |
135 |
137 |
136 $resDoc = $docList[0]; |
138 $resDoc = $docList[0]; |
137 |
139 |
138 $this->assertInstanceOf(Document::class, $resDoc, "Res doc must be a Document"); |
140 $this->assertInstanceOf(DocumentResult::class, $resDoc, "Res doc must be a Document"); |
139 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $resDoc->getId(), "id must be crdo..."); |
141 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $resDoc->getId(), "id must be crdo..."); |
140 $this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...'); |
142 $this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...'); |
141 $this->assertNotNull($resDoc->getGraph(), 'Graph must not be null'); |
143 $this->assertNotNull($resDoc->getGraph(), 'Graph must not be null'); |
142 |
144 |
143 } |
145 } |
153 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); |
155 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); |
154 $this->assertNotNull($res->getGraph(), "Graph shoul not be null"); |
156 $this->assertNotNull($res->getGraph(), "Graph shoul not be null"); |
155 $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"); |
157 $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"); |
156 $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); |
158 $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); |
157 } |
159 } |
|
160 |
|
161 public function testGetShort() { |
|
162 |
|
163 $expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738'; |
|
164 $returnedGraph = new EasyRdf\Graph($expectedId, sprintf(DocumentRepositoryIntegrationTest::TEST_DOC,config('corpusparole.corpus_doc_id_base_uri'))); |
|
165 |
|
166 $res = $this->documentRepository->get('crdo-ALA_738', true); |
|
167 |
|
168 $this->assertInstanceOf(DocumentResult::class, $res, "Result must be of type DocumentResult"); |
|
169 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); |
|
170 $this->assertNotNull($res->getGraph(), "Graph shoul not be null"); |
|
171 $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"); |
|
172 $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); |
|
173 } |
|
174 |
158 |
175 |
159 public function testSave() { |
176 public function testSave() { |
160 |
177 |
161 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", $this->graph); |
178 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", $this->graph); |
162 $doc->updateDiscourseTypes(['oratory','drama','narrative']); |
179 $doc->updateDiscourseTypes(['oratory','drama','narrative']); |