server/src/tests/Models/DocumentTest.php
changeset 502 74fba571487e
parent 501 7b2dcd2b31c1
equal deleted inserted replaced
501:7b2dcd2b31c1 502:74fba571487e
    32         $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
    32         $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
    33 
    33 
    34         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
    34         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
    35 
    35 
    36         $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
    36         $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
       
    37     }
       
    38 
       
    39     public function testCocoonId() {
       
    40         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
       
    41         $this->assertEquals('crdo-CFPP2000_35_SOUND',$doc->getCocoonId(),'Must have the correct cocoon id');
       
    42     }
       
    43     public function testCocoonIdWithIdBefore() {
       
    44         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
       
    45         $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
       
    46         $this->assertEquals('crdo-CFPP2000_35_SOUND',$doc->getCocoonId(),'Must have the correct cocoon id');
    37     }
    47     }
    38 
    48 
    39     public function testTitle() {
    49     public function testTitle() {
    40         $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
    50         $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
    41 
    51 
   425         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
   435         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
   426 
   436 
   427         $json = $doc->jsonSerialize();
   437         $json = $doc->jsonSerialize();
   428 
   438 
   429         $this->assertTrue(is_array($json), 'Returned json must be an array');
   439         $this->assertTrue(is_array($json), 'Returned json must be an array');
   430         $this->assertEquals(
   440         $expectedKeys = [ "id", "cocoonId", "uri", "title", "languages", "modified", "issued",
   431             [ "id", "uri", "title", "languages", "modified", "issued",
       
   432               "created", "publishers", "contributors", "subjects", "types",
   441               "created", "publishers", "contributors", "subjects", "types",
   433               "transcript", "mediaArray", "geoInfo", "descriptions",
   442               "transcript", "mediaArray", "geoInfo", "descriptions",
   434               "alternativeTitle", "rights"],
   443               "alternativeTitle", "rights"];
   435             array_keys($json)
   444         sort($expectedKeys);
   436         );
   445         $arrayKeys = array_keys($json);
       
   446         sort($arrayKeys);
       
   447         $this->assertEquals($expectedKeys, $arrayKeys);
   437         $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']);
   448         $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']);
   438         $this->assertTrue(is_array($json['transcript']));
   449         $this->assertTrue(is_array($json['transcript']));
   439         $this->assertTrue(is_array($json['mediaArray']));
   450         $this->assertTrue(is_array($json['mediaArray']));
   440         $this->assertTrue(is_array($json['subjects']));
   451         $this->assertTrue(is_array($json['subjects']));
   441         $this->assertTrue(is_array($json['types']));
   452         $this->assertTrue(is_array($json['types']));
   442 
   453 
   443     }
   454     }
   444 
   455 
       
   456     public function testJsonSerializeSetCountryCode() {
       
   457         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
       
   458 
       
   459         $doc->setCountryCode('3017382');
       
   460         $json = $doc->jsonSerialize();
       
   461 
       
   462         $this->assertTrue(is_array($json), 'Returned json must be an array');
       
   463         $expectedKeys = [ "id", "cocoonId", "uri", "title", "languages", "modified", "issued",
       
   464               "created", "publishers", "contributors", "subjects", "types",
       
   465               "transcript", "mediaArray", "geoInfo", "descriptions",
       
   466               "alternativeTitle", "rights", 'countryCode' ];
       
   467         sort($expectedKeys);
       
   468         $arrayKeys = array_keys($json);
       
   469         sort($arrayKeys);
       
   470         $this->assertEquals($expectedKeys, $arrayKeys);
       
   471         $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']);
       
   472         $this->assertTrue(is_array($json['transcript']));
       
   473         $this->assertTrue(is_array($json['mediaArray']));
       
   474         $this->assertTrue(is_array($json['subjects']));
       
   475         $this->assertTrue(is_array($json['types']));
       
   476 
       
   477     }
       
   478 
   445     public function testAddGeoInfo() {
   479     public function testAddGeoInfo() {
   446 
   480 
   447         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_GEOINFO']);
   481         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_GEOINFO']);
   448         //$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
   482         //$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
   449 
   483