server/src/tests/Models/DocumentTest.php
changeset 143 023b6d467566
parent 138 3079cbf80006
child 168 17f10b56c079
equal deleted inserted replaced
142:86fcf0c837c0 143:023b6d467566
    14     @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
    14     @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
    15     @prefix owl: <http://www.w3.org/2002/07/owl#> .
    15     @prefix owl: <http://www.w3.org/2002/07/owl#> .
    16     @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    16     @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    17     @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
    17     @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
    18 
    18 
    19     <http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND> a <http://www.openarchives.org/ore/terms/Aggregation> ;
    19     <%1\$scrdo-CFPP2000_35_SOUND> a <http://www.openarchives.org/ore/terms/Aggregation> ;
    20         <http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> ;
    20         <http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> ;
    21         <http://www.europeana.eu/schemas/edm/dataProvider> "Langage et langues : description, théorisation, transmission" ;
    21         <http://www.europeana.eu/schemas/edm/dataProvider> "Langage et langues : description, théorisation, transmission" ;
    22         <http://www.europeana.eu/schemas/edm/hasView> <http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml> , <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3> , <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav> ;
    22         <http://www.europeana.eu/schemas/edm/hasView> <http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml> , <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3> , <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav> ;
    23         <http://www.europeana.eu/schemas/edm/isShownAt> <http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-CFPP2000_35_SOUND> ;
    23         <http://www.europeana.eu/schemas/edm/isShownAt> <http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-CFPP2000_35_SOUND> ;
    24         <http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> ;
    24         <http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> ;
    31         <http://purl.org/dc/terms/extent> "PT48M26S" ;
    31         <http://purl.org/dc/terms/extent> "PT48M26S" ;
    32         <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
    32         <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
    33         <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
    33         <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
    34         <http://purl.org/dc/elements/1.1/contributor> <http://viaf.org/viaf/93752300> , "Tanguy, Noalig" , "Chevrier, Michel" , "Kiliç, Ozgur" , "Salvegas, Etienne" , "du-Breuil-de-Pont-en-Auge, Augustin" , "du-Breuil-de-Pont-en-Auge, Benoît" ;
    34         <http://purl.org/dc/elements/1.1/contributor> <http://viaf.org/viaf/93752300> , "Tanguy, Noalig" , "Chevrier, Michel" , "Kiliç, Ozgur" , "Salvegas, Etienne" , "du-Breuil-de-Pont-en-Auge, Augustin" , "du-Breuil-de-Pont-en-Auge, Benoît" ;
    35         <http://purl.org/dc/elements/1.1/description> "Enregistrement issu du Corpus de Français Parlé Parisien des années 2000 (CFPP2000)"@fr , "Quartier(s) concerné(s) : Paris 3e, et 20e (pour l'âge adulte); Anonymisation : Noalig TANGUY;"@fr ;
    35         <http://purl.org/dc/elements/1.1/description> "Enregistrement issu du Corpus de Français Parlé Parisien des années 2000 (CFPP2000)"@fr , "Quartier(s) concerné(s) : Paris 3e, et 20e (pour l'âge adulte); Anonymisation : Noalig TANGUY;"@fr ;
    36         <http://purl.org/dc/elements/1.1/identifier> "ark:/87895/1.17-375004" , "corpusparole:crdo-CFPP2000_35_SOUNDid" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35" , "Cote producteur: [03-01] Ozgur_Kilic_H_32_alii_3e"@fr , "ark:/87895/1.17-372593" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35_SOUND" ;
    36         <http://purl.org/dc/elements/1.1/identifier> "ark:/87895/1.17-375004" , "%2\$scrdo-CFPP2000_35_SOUNDid" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35" , "Cote producteur: [03-01] Ozgur_Kilic_H_32_alii_3e"@fr , "ark:/87895/1.17-372593" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35_SOUND" ;
    37         <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
    37         <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
    38         <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/142432638>;
    38         <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/142432638>;
    39         <http://purl.org/dc/elements/1.1/subject> <http://ark.bnf.fr/ark:/12148/cb13318415c> , "anthropological_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "lexicography"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "phonetics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://lexvo.org/id/iso639-3/fra> , <http://ark.bnf.fr/ark:/12148/cb133188907> , <http://ark.bnf.fr/ark:/12148/cb11932762f> , "general_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb133183660> , "text_and_corpus_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "Français"@fr , <http://ark.bnf.fr/ark:/12148/cb122368540> , "phonology"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "semantics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "sociolinguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "syntax"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "typology"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb119418302> , <http://ark.bnf.fr/ark:/12148/cb135540729> , "discourse_analysis"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "historical_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "language_documentation"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb133192210> , <http://ark.bnf.fr/ark:/12148/cb119377452> , <http://ark.bnf.fr/ark:/12148/cb13320451h> , <http://ark.bnf.fr/ark:/12148/cb13318422n> , <http://ark.bnf.fr/ark:/12148/cb11975823c> , "mathematical_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> ;
    39         <http://purl.org/dc/elements/1.1/subject> <http://ark.bnf.fr/ark:/12148/cb13318415c> , "anthropological_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "lexicography"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "phonetics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://lexvo.org/id/iso639-3/fra> , <http://ark.bnf.fr/ark:/12148/cb133188907> , <http://ark.bnf.fr/ark:/12148/cb11932762f> , "general_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb133183660> , "text_and_corpus_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "Français"@fr , <http://ark.bnf.fr/ark:/12148/cb122368540> , "phonology"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "semantics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "sociolinguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "syntax"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "typology"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb119418302> , <http://ark.bnf.fr/ark:/12148/cb135540729> , "discourse_analysis"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "historical_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "language_documentation"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb133192210> , <http://ark.bnf.fr/ark:/12148/cb119377452> , <http://ark.bnf.fr/ark:/12148/cb13320451h> , <http://ark.bnf.fr/ark:/12148/cb13318422n> , <http://ark.bnf.fr/ark:/12148/cb11975823c> , "mathematical_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> ;
    40         <http://purl.org/dc/elements/1.1/title> "Entretien de Ozgur Kiliç 2"@fr ;
    40         <http://purl.org/dc/elements/1.1/title> "Entretien de Ozgur Kiliç 2"@fr ;
    41         <http://purl.org/dc/elements/1.1/type> <http://ark.bnf.fr/ark:/12148/cb11932135w> , <http://ark.bnf.fr/ark:/12148/cb12481481z> , <http://purl.org/dc/dcmitype/Sound> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , <http://purl.org/dc/dcmitype/Text> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "report"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "unintelligible_speech"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
    41         <http://purl.org/dc/elements/1.1/type> <http://ark.bnf.fr/ark:/12148/cb11932135w> , <http://ark.bnf.fr/ark:/12148/cb12481481z> , <http://purl.org/dc/dcmitype/Sound> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , <http://purl.org/dc/dcmitype/Text> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "report"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "unintelligible_speech"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
    91 
    91 
    92 
    92 
    93     public function setUp() {
    93     public function setUp() {
    94 
    94 
    95         parent::setup();
    95         parent::setup();
    96         $this->graph = new EasyRdf\Graph("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", DocumentTest::TEST_DOC);
    96         $this->graph = new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(DocumentTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme')));
    97 
    97 
    98     }
    98     }
    99 
    99 
   100     public function testConstructor() {
   100     public function testConstructor() {
   101         $this->assertNotNull($this->graph, 'Graph shoud not be null');
   101         $this->assertNotNull($this->graph, 'Graph shoud not be null');
   102 
   102 
   103         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   103         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   104 
   104 
   105         $this->assertEquals('corpusparole:crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
   105         $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
   106     }
   106     }
   107 
   107 
   108     public function testTitle() {
   108     public function testTitle() {
   109         $this->assertNotNull($this->graph, 'Graph shoud not be null');
   109         $this->assertNotNull($this->graph, 'Graph shoud not be null');
   110 
   110 
   111         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   111         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   112 
   112 
   113         $this->assertEquals("Entretien de Ozgur Kiliç 2",$doc->getTitle(),'Must have correct title');
   113         $this->assertEquals("Entretien de Ozgur Kiliç 2",$doc->getTitle(),'Must have correct title');
   114         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getTitle(), "Title must be a literal");
   114         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getTitle(), "Title must be a literal");
   115         $this->assertEquals('fr', $doc->getTitle()->getLang(), "Language title must be fr");
   115         $this->assertEquals('fr', $doc->getTitle()->getLang(), "Language title must be fr");
   116     }
   116     }
   117 
   117 
   118     public function testModified() {
   118     public function testModified() {
   119         $this->assertNotNull($this->graph, 'Graph shoud not be null');
   119         $this->assertNotNull($this->graph, 'Graph shoud not be null');
   120 
   120 
   121         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   121         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   122         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
   122         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
   123         $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
   123         $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
   124         $this->assertEquals("2013-10-12T14:35:57+02:00", $doc->getModified(), "modified must be 2013-10-12T14:35:57+02:00");
   124         $this->assertEquals("2013-10-12T14:35:57+02:00", $doc->getModified(), "modified must be 2013-10-12T14:35:57+02:00");
   125 
   125 
   126     }
   126     }
   127 
   127 
   128     public function testSetModified() {
   128     public function testSetModified() {
   129         $currentTime = gmdate(DateTime::ATOM);
   129         $currentTime = gmdate(DateTime::ATOM);
   130         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   130         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   131         $doc->setModified($currentTime);
   131         $doc->setModified($currentTime);
   132         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
   132         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
   133         $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
   133         $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
   134         $this->assertEquals(preg_replace('/[\+\-]00(\:?)00$/', 'Z', $currentTime), $doc->getModified()->getValue(), "modified must be $currentTime");
   134         $this->assertEquals(preg_replace('/[\+\-]00(\:?)00$/', 'Z', $currentTime), $doc->getModified()->getValue(), "modified must be $currentTime");
   135     }
   135     }
   136 
   136 
   137     public function testSetModifiedNull() {
   137     public function testSetModifiedNull() {
   138         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   138         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   139         $doc->setModified();
   139         $doc->setModified();
   140         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
   140         $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
   141         $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
   141         $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
   142         $foundDateTime = \DateTime::createFromFormat(\DateTime::ATOM, $doc->getModified()->getValue());
   142         $foundDateTime = \DateTime::createFromFormat(\DateTime::ATOM, $doc->getModified()->getValue());
   143         $nowUTC = new \DateTime('now', new \DateTimeZone("UTC"));
   143         $nowUTC = new \DateTime('now', new \DateTimeZone("UTC"));
   144         $this->assertTrue($nowUTC->getTimestamp() -  $foundDateTime->getTimestamp() < 2, "must have less than 2 seconds diff");
   144         $this->assertTrue($nowUTC->getTimestamp() -  $foundDateTime->getTimestamp() < 2, "must have less than 2 seconds diff");
   145     }
   145     }
   146 
   146 
   147     public function testPublisher() {
   147     public function testPublisher() {
   148 
   148 
   149         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   149         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   150 
   150 
   151         $this->assertCount(1, $doc->getPublishers(), 'Publisher is an array of size 1');
   151         $this->assertCount(1, $doc->getPublishers(), 'Publisher is an array of size 1');
   152         $this->assertInstanceOf('EasyRdf\Resource', $doc->getPublishers()[0], 'publisher is a resource');
   152         $this->assertInstanceOf('EasyRdf\Resource', $doc->getPublishers()[0], 'publisher is a resource');
   153         $this->assertEquals("http://viaf.org/viaf/142432638", $doc->getPublishers()[0]->getUri(),"");
   153         $this->assertEquals("http://viaf.org/viaf/142432638", $doc->getPublishers()[0]->getUri(),"");
   154     }
   154     }
   155 
   155 
   156     public function testMediaArray() {
   156     public function testMediaArray() {
   157         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   157         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   158 
   158 
   159         $this->assertCount(4, $doc->getMediaArray(), "Media array must be of size 4");
   159         $this->assertCount(4, $doc->getMediaArray(), "Media array must be of size 4");
   160         //print_r($doc->getMediaArray());
   160         //print_r($doc->getMediaArray());
   161         foreach($doc->getMediaArray() as $url => $media) {
   161         foreach($doc->getMediaArray() as $url => $media) {
   162             $this->assertArrayHasKey('format', $media, "media has 'format key'");
   162             $this->assertArrayHasKey('format', $media, "media has 'format key'");
   199 
   199 
   200         }
   200         }
   201     }
   201     }
   202 
   202 
   203     public function testGetTypes() {
   203     public function testGetTypes() {
   204         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   204         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   205 
   205 
   206         $this->assertCount(8, $doc->getTypes(), "types array must be of size 5");
   206         $this->assertCount(8, $doc->getTypes(), "types array must be of size 5");
   207 
   207 
   208         foreach($doc->getTypes() as $type) {
   208         foreach($doc->getTypes() as $type) {
   209             $this->assertThat(
   209             $this->assertThat(
   215             );
   215             );
   216         }
   216         }
   217     }
   217     }
   218 
   218 
   219     public function testGetOtherTypes() {
   219     public function testGetOtherTypes() {
   220         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   220         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   221 
   221 
   222         $this->assertCount(5, $doc->getOtherTypes(), "types array must be of size 5");
   222         $this->assertCount(5, $doc->getOtherTypes(), "types array must be of size 5");
   223 
   223 
   224         foreach($doc->getTypes() as $type) {
   224         foreach($doc->getTypes() as $type) {
   225             $this->assertThat(
   225             $this->assertThat(
   231             );
   231             );
   232         }
   232         }
   233     }
   233     }
   234 
   234 
   235     public function testGetDiscourseTypes() {
   235     public function testGetDiscourseTypes() {
   236         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   236         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   237 
   237 
   238         $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3");
   238         $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3");
   239 
   239 
   240         $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $doc->getDiscourseTypes(), "Result contains only literals");
   240         $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $doc->getDiscourseTypes(), "Result contains only literals");
   241         $type = $doc->getDiscourseTypes()[0];
   241         $type = $doc->getDiscourseTypes()[0];
   242         $this->assertEquals("narrative", $type->getValue(), "discourse type is narrative");
   242         $this->assertEquals("narrative", $type->getValue(), "discourse type is narrative");
   243         $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $type->getDatatypeUri(), "discourse type url");
   243         $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $type->getDatatypeUri(), "discourse type url");
   244     }
   244     }
   245 
   245 
   246     public function testCloneDocument() {
   246     public function testCloneDocument() {
   247         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   247         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   248 
   248 
   249         $doc2 = clone $doc;
   249         $doc2 = clone $doc;
   250 
   250 
   251         $this->assertNotSame($doc, $doc2, "documents must not be the same");
   251         $this->assertNotSame($doc, $doc2, "documents must not be the same");
   252         $this->assertNotSame($doc->getGraph(), $doc2->getGraph(), "documents must not be the same");
   252         $this->assertNotSame($doc->getGraph(), $doc2->getGraph(), "documents must not be the same");
   253 
   253 
   254         $this->assertTrue(EasyRdf\Isomorphic::isomorphic($doc->getGraph(), $doc2->getGraph()),"graph must be isomorphic");
   254         $this->assertTrue(EasyRdf\Isomorphic::isomorphic($doc->getGraph(), $doc2->getGraph()),"graph must be isomorphic");
   255     }
   255     }
   256 
   256 
   257     public function testIsIsomorphic() {
   257     public function testIsIsomorphic() {
   258         $doc1 = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   258         $doc1 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   259         $doc2 = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", new EasyRdf\Graph("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", DocumentTest::TEST_DOC));
   259         $doc2 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(DocumentTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))));
   260 
   260 
   261         $this->assertTrue($doc1->isIsomorphic($doc2),"document must be isomorphic");
   261         $this->assertTrue($doc1->isIsomorphic($doc2),"document must be isomorphic");
   262 
   262 
   263         $doc2->addLiteral('dc11:type', new EasyRdf\Literal("oratory", null, Config::get('OLAC_DISCOURSE_TYPE')['uri']));
   263         $doc2->addLiteral('dc11:type', new EasyRdf\Literal("oratory", null, Config::get('OLAC_DISCOURSE_TYPE')['uri']));
   264 
   264 
   267 
   267 
   268     public function testUpdateDiscourseTypes() {
   268     public function testUpdateDiscourseTypes() {
   269 
   269 
   270         $newDiscourseTypes = ['oratory','dialogue','narrative', 'formulaic', 'ludic'];
   270         $newDiscourseTypes = ['oratory','dialogue','narrative', 'formulaic', 'ludic'];
   271 
   271 
   272         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   272         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   273         $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3");
   273         $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3");
   274 
   274 
   275         $doc->updateDiscourseTypes($newDiscourseTypes);
   275         $doc->updateDiscourseTypes($newDiscourseTypes);
   276 
   276 
   277         $this->assertCount(5, $doc->getDiscourseTypes(), "types array must be of size 5");
   277         $this->assertCount(5, $doc->getDiscourseTypes(), "types array must be of size 5");
   285 
   285 
   286     public function testUpdateDiscourseTypesDelta() {
   286     public function testUpdateDiscourseTypesDelta() {
   287 
   287 
   288         $newDiscourseTypes = ['oratory','dialogue','narrative', 'formulaic', 'ludic'];
   288         $newDiscourseTypes = ['oratory','dialogue','narrative', 'formulaic', 'ludic'];
   289 
   289 
   290         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   290         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   291 
   291 
   292         $doc->updateDiscourseTypes($newDiscourseTypes);
   292         $doc->updateDiscourseTypes($newDiscourseTypes);
   293 
   293 
   294         $this->assertTrue($doc->isDirty());
   294         $this->assertTrue($doc->isDirty());
   295 
   295 
   296         $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
   296         $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
   297 
   297 
   298         $delta = $doc->getDeltaList()[0];
   298         $delta = $doc->getDeltaList()[0];
   299 
   299 
   300         $this->assertEquals("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $delta->getDeletedGraph()->getUri(), "uri of deleted graph must be ok");
   300         $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $delta->getDeletedGraph()->getUri(), "uri of deleted graph must be ok");
   301         $this->assertEquals("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $delta->getAddedGraph()->getUri(), "uri of added graph must be ok");
   301         $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $delta->getAddedGraph()->getUri(), "uri of added graph must be ok");
   302 
   302 
   303         $this->assertEquals(3, $delta->getDeletedGraph()->countTriples(), "deleted graph must have only 3 triples");
   303         $this->assertEquals(3, $delta->getDeletedGraph()->countTriples(), "deleted graph must have only 3 triples");
   304         $this->assertEquals(5, $delta->getAddedGraph()->countTriples(), "deleted graph must have only 5 triples");
   304         $this->assertEquals(5, $delta->getAddedGraph()->countTriples(), "deleted graph must have only 5 triples");
   305 
   305 
   306         $resQueryDiscourseType = $delta->getAddedGraph()->allLiterals($doc->getProvidedCHO(), 'dc11:type');
   306         $resQueryDiscourseType = $delta->getAddedGraph()->allLiterals($doc->getProvidedCHO(), 'dc11:type');
   313         }
   313         }
   314 
   314 
   315     }
   315     }
   316 
   316 
   317     public function testUpdateTitle() {
   317     public function testUpdateTitle() {
   318         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   318         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   319 
   319 
   320         $oldTitle = $doc->getTitle();
   320         $oldTitle = $doc->getTitle();
   321 
   321 
   322         $doc->setTitle("new title", "en");
   322         $doc->setTitle("new title", "en");
   323 
   323 
   341 
   341 
   342     public function testUpdateDiscourseTypesIsomorphic() {
   342     public function testUpdateDiscourseTypesIsomorphic() {
   343 
   343 
   344         $newDiscourseTypes = ['oratory','dialogue','narrative'];
   344         $newDiscourseTypes = ['oratory','dialogue','narrative'];
   345 
   345 
   346         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   346         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   347         $doc->updateDiscourseTypes($newDiscourseTypes);
   347         $doc->updateDiscourseTypes($newDiscourseTypes);
   348 
   348 
   349         $doc2 = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", new EasyRdf\Graph("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", DocumentTest::TEST_DOC));
   349         $doc2 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(DocumentTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))));
   350 
   350 
   351         $this->assertFalse($doc->isIsomorphic($doc2),"document must not be isomorphic after adding discourse type");
   351         $this->assertFalse($doc->isIsomorphic($doc2),"document must not be isomorphic after adding discourse type");
   352     }
   352     }
   353 
   353 
   354     public function testGetContributors() {
   354     public function testGetContributors() {
   355         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   355         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   356 
   356 
   357         $contributors = $doc->getContributors();
   357         $contributors = $doc->getContributors();
   358 
   358 
   359         $this->assertNotEmpty($contributors, "The contributors array should not be empty");
   359         $this->assertNotEmpty($contributors, "The contributors array should not be empty");
   360         $this->assertCount(8, $contributors, "The contributors array should have 8 elements");
   360         $this->assertCount(8, $contributors, "The contributors array should have 8 elements");
   366             $this->assertContains($contribDef['role'], CocoonUtils::OLAC_ROLES, "Role should be in OLAC_ROLES");
   366             $this->assertContains($contribDef['role'], CocoonUtils::OLAC_ROLES, "Role should be in OLAC_ROLES");
   367         }
   367         }
   368     }
   368     }
   369 
   369 
   370     public function testSetContributors() {
   370     public function testSetContributors() {
   371         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   371         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   372 
   372 
   373         $contributors = $doc->getContributors();
   373         $contributors = $doc->getContributors();
   374 
   374 
   375         $contribList = [[
   375         $contribList = [[
   376             "name"=> "Guylaine Brun-Trigaud",
   376             "name"=> "Guylaine Brun-Trigaud",
   443         $this->assertTrue($foundJaneAusten, "Jane austenn not foud");
   443         $this->assertTrue($foundJaneAusten, "Jane austenn not foud");
   444 
   444 
   445     }
   445     }
   446 
   446 
   447     public function testGetSubjects() {
   447     public function testGetSubjects() {
   448         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   448         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   449 
   449 
   450         $subjects = $doc->getSubjects();
   450         $subjects = $doc->getSubjects();
   451 
   451 
   452         $this->assertCount(28, $subjects, "Must have 28 subjects");
   452         $this->assertCount(28, $subjects, "Must have 28 subjects");
   453 
   453 
   461             );
   461             );
   462         }
   462         }
   463     }
   463     }
   464 
   464 
   465     public function testSetSubjects() {
   465     public function testSetSubjects() {
   466         $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-CFPP2000_35_SOUND", $this->graph);
   466         $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
   467 
   467 
   468         $newSubjects = [
   468         $newSubjects = [
   469             "http://ark.bnf.fr/ark:/12148/cb13318415c",
   469             "http://ark.bnf.fr/ark:/12148/cb13318415c",
   470             "http://ark.bnf.fr/ark:/12148/cb133188907",
   470             "http://ark.bnf.fr/ark:/12148/cb133188907",
   471             "http://ark.bnf.fr/ark:/12148/cb11932762f",
   471             "http://ark.bnf.fr/ark:/12148/cb11932762f",