server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php
changeset 371 0365fd9977a4
parent 326 226d5b17a119
child 405 f239c8c5bb94
equal deleted inserted replaced
370:d7c5b43d309a 371:0365fd9977a4
   208 
   208 
   209 
   209 
   210     public function testSave() {
   210     public function testSave() {
   211 
   211 
   212         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", $this->graph);
   212         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", $this->graph);
   213         $doc->updateDiscourseTypes(['oratory','drama','narrative']);
   213         $updatedDiscourseTypes = ["http://ark.bnf.fr/ark:/12148/cb13319048g", "http://ark.bnf.fr/ark:/12148/cb11949715t" , "http://ark.bnf.fr/ark:/12148/cb119783362"];
       
   214         $doc->updateDiscourseTypes($updatedDiscourseTypes);
   214 
   215 
   215         $res = $this->documentRepository->save($doc);
   216         $res = $this->documentRepository->save($doc);
   216 
   217 
   217         $this->assertTrue($res, 'Has started a transaction');
   218         $this->assertTrue($res, 'Has started a transaction');
   218 
   219 
   219         $res = $this->documentRepository->get('crdo-ALA_738');
   220         $res = $this->documentRepository->get('crdo-ALA_738');
   220 
   221 
   221         $discoursesTypes = $res->getDiscourseTypes();
   222         $discoursesTypes = $res->getDiscourseTypes();
   222 
   223 
   223         $this->assertCount(3, $discoursesTypes, "types array must be of size 1");
   224         $this->assertCount(3, $discoursesTypes, "types array must be of size 3");
   224 
   225 
   225         $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $discoursesTypes, "Result contains only literals");
   226         $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $discoursesTypes, "Result contains only resources");
   226 
   227 
   227         $newDiscoursesTypes = [];
   228         $newDiscoursesTypes = [];
   228         foreach($discoursesTypes as $dt) {
   229         foreach($discoursesTypes as $dt) {
   229             array_push($newDiscoursesTypes, $dt->getValue());
   230             array_push($newDiscoursesTypes, $dt->getUri());
   230             $this->assertContains($dt->getValue(),['oratory','drama','narrative'],'Value in [oratory,drama,narrative]');
   231             $this->assertContains($dt->getUri(), $updatedDiscourseTypes,"Value in ".print_r($updatedDiscourseTypes, true));
   231             $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $dt->getDatatypeUri(), "discourse type url");
       
   232         }
   232         }
   233         sort($newDiscoursesTypes);
   233         sort($newDiscoursesTypes);
   234         $this->assertEquals(['drama', 'narrative', 'oratory'], $newDiscoursesTypes, "array type must the same");
   234         sort($updatedDiscourseTypes);
       
   235 
       
   236         $this->assertEquals($updatedDiscourseTypes, $newDiscoursesTypes, "array type must the same");
   235     }
   237     }
   236 
   238 
   237     public function testCount() {
   239     public function testCount() {
   238         $res = $this->documentRepository->getCount();
   240         $res = $this->documentRepository->getCount();
   239 
   241