1 <?php |
1 <?php |
2 |
2 |
3 use CorpusParole\Models\Document; |
3 use CorpusParole\Models\Document; |
4 use CorpusParole\Libraries\CocoonUtils; |
4 use CorpusParole\Libraries\CocoonUtils; |
|
5 |
|
6 use EasyRdf\RdfNamespace; |
5 |
7 |
6 /** |
8 /** |
7 * |
9 * |
8 */ |
10 */ |
9 class DocumentTest extends TestCase { |
11 class DocumentTest extends TestCase { |
10 |
12 |
11 const TEST_DOC = <<<EOT |
13 const TEST_INPUT_DOCS = [ |
12 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
14 'TEST' => __DIR__.'/files/DocumentTest/test_doc.ttl', |
13 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
15 'TEST_NO_GEOINFO' => __DIR__.'/files/DocumentTest/test_no_geoinfo.ttl', |
14 @prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
16 ]; |
15 @prefix owl: <http://www.w3.org/2002/07/owl#> . |
17 |
16 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
18 private $inputGraphes = []; |
17 @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
|
18 |
|
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> ; |
|
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> ; |
|
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> ; |
|
25 <http://www.europeana.eu/schemas/edm/provider> "Corpus de la Parole"@fr ; |
|
26 <http://www.europeana.eu/schemas/edm/rights> <http://creativecommons.org/licenses/by-nc-sa/4.0/> . |
|
27 |
|
28 <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ; |
|
29 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
30 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
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> ; |
|
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" ; |
|
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" , "%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> ; |
|
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> ; |
|
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> ; |
|
42 <http://purl.org/dc/terms/available> "2013-10-12"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
43 <http://purl.org/dc/terms/spatial> [ |
|
44 a <http://www.europeana.eu/schemas/edm/Place> ; |
|
45 owl:sameAs <http://sws.geonames.org/6618626/> ; |
|
46 <http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr |
|
47 ]; |
|
48 <http://www.europeana.eu/schemas/edm/isGatheredInto> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000> ; |
|
49 <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/93752300> ; |
|
50 <http://www.language-archives.org/OLAC/1.1/interviewer> <http://viaf.org/viaf/93752300> ; |
|
51 <http://www.language-archives.org/OLAC/1.1/transcriber> "Tanguy, Noalig" ; |
|
52 <http://purl.org/dc/elements/1.1/coverage> "Quartier concerné : 3e"@fr ; |
|
53 <http://www.language-archives.org/OLAC/1.1/responder> "Chevrier, Michel" , "Kiliç, Ozgur" , "Salvegas, Etienne" , "du-Breuil-de-Pont-en-Auge, Augustin" , "du-Breuil-de-Pont-en-Auge, Benoît" ; |
|
54 <http://purl.org/dc/elements/1.1/relation> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_31_SOUND> . |
|
55 |
|
56 |
|
57 <http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
58 <http://purl.org/dc/elements/1.1/format> "application/xml"^^<http://purl.org/dc/terms/IMT> ; |
|
59 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
60 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
61 <http://purl.org/dc/terms/issued> "2013-11-04T22:20:07+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
62 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
63 <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber> . |
|
64 |
|
65 <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
66 <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
|
67 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
68 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
69 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
70 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
71 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> . |
|
72 |
|
73 <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
74 <http://purl.org/dc/elements/1.1/format> "audio/mpeg"^^<http://purl.org/dc/terms/IMT> ; |
|
75 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
76 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
77 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
78 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
79 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
80 <http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> . |
|
81 |
|
82 <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
83 <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
|
84 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
85 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
86 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
87 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
88 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
89 <http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> . |
|
90 EOT; |
|
91 |
|
92 |
19 |
93 public function setUp() { |
20 public function setUp() { |
94 |
|
95 parent::setup(); |
21 parent::setup(); |
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'))); |
22 |
|
23 foreach(self::TEST_INPUT_DOCS as $key => $inputDoc) { |
|
24 $this->inputGraphes[$key] = new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(file_get_contents($inputDoc), config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))); |
|
25 } |
|
26 |
97 |
27 |
98 } |
28 } |
99 |
29 |
100 public function testConstructor() { |
30 public function testConstructor() { |
101 $this->assertNotNull($this->graph, 'Graph shoud not be null'); |
31 $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); |
102 |
32 |
103 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
33 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
104 |
34 |
105 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id'); |
35 $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id'); |
106 } |
36 } |
107 |
37 |
108 public function testTitle() { |
38 public function testTitle() { |
109 $this->assertNotNull($this->graph, 'Graph shoud not be null'); |
39 $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); |
110 |
40 |
111 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
41 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
112 |
42 |
113 $this->assertEquals("Entretien de Ozgur Kiliç 2",$doc->getTitle(),'Must have correct title'); |
43 $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"); |
44 $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getTitle(), "Title must be a literal"); |
115 $this->assertEquals('fr', $doc->getTitle()->getLang(), "Language title must be fr"); |
45 $this->assertEquals('fr', $doc->getTitle()->getLang(), "Language title must be fr"); |
116 } |
46 } |
117 |
47 |
|
48 |
118 public function testModified() { |
49 public function testModified() { |
119 $this->assertNotNull($this->graph, 'Graph shoud not be null'); |
50 $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); |
120 |
51 |
121 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
52 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
122 $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal"); |
53 $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"); |
54 $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"); |
55 $this->assertEquals("2013-10-12T14:35:57+02:00", $doc->getModified(), "modified must be 2013-10-12T14:35:57+02:00"); |
125 |
56 |
126 } |
57 } |
127 |
58 |
128 public function testSetModified() { |
59 public function testSetModified() { |
129 $currentTime = gmdate(DateTime::ATOM); |
60 $currentTime = gmdate(DateTime::ATOM); |
130 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
61 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
131 $doc->setModified($currentTime); |
62 $doc->setModified($currentTime); |
132 $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal"); |
63 $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"); |
64 $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"); |
65 $this->assertEquals(preg_replace('/[\+\-]00(\:?)00$/', 'Z', $currentTime), $doc->getModified()->getValue(), "modified must be $currentTime"); |
135 } |
66 } |
136 |
67 |
137 public function testSetModifiedNull() { |
68 public function testSetModifiedNull() { |
138 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
69 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
139 $doc->setModified(); |
70 $doc->setModified(); |
140 $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal"); |
71 $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"); |
72 $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()); |
73 $foundDateTime = \DateTime::createFromFormat(\DateTime::ATOM, $doc->getModified()->getValue()); |
143 $nowUTC = new \DateTime('now', new \DateTimeZone("UTC")); |
74 $nowUTC = new \DateTime('now', new \DateTimeZone("UTC")); |
144 $this->assertTrue($nowUTC->getTimestamp() - $foundDateTime->getTimestamp() < 2, "must have less than 2 seconds diff"); |
75 $this->assertTrue($nowUTC->getTimestamp() - $foundDateTime->getTimestamp() < 2, "must have less than 2 seconds diff"); |
145 } |
76 } |
146 |
77 |
147 public function testPublisher() { |
78 public function testPublisher() { |
148 |
79 |
149 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
80 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
150 |
81 |
151 $this->assertCount(1, $doc->getPublishers(), 'Publisher is an array of size 1'); |
82 $this->assertCount(1, $doc->getPublishers(), 'Publisher is an array of size 1'); |
152 $this->assertInstanceOf('EasyRdf\Resource', $doc->getPublishers()[0], 'publisher is a resource'); |
83 $this->assertInstanceOf('EasyRdf\Resource', $doc->getPublishers()[0], 'publisher is a resource'); |
153 $this->assertEquals("http://viaf.org/viaf/142432638", $doc->getPublishers()[0]->getUri(),""); |
84 $this->assertEquals("http://viaf.org/viaf/142432638", $doc->getPublishers()[0]->getUri(),""); |
154 } |
85 } |
155 |
86 |
156 public function testMediaArray() { |
87 public function testMediaArray() { |
157 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
88 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
158 |
89 |
159 $this->assertCount(3, $doc->getMediaArray(), "Media array must be of size 3"); |
90 $this->assertCount(3, $doc->getMediaArray(), "Media array must be of size 3"); |
160 //print_r($doc->getMediaArray()); |
91 //print_r($doc->getMediaArray()); |
161 foreach($doc->getMediaArray() as $media) { |
92 foreach($doc->getMediaArray() as $media) { |
162 $this->assertInstanceOf('CorpusParole\Models\MediaResource', $media, "media msute of type MediaResource"); |
93 $this->assertInstanceOf('CorpusParole\Models\MediaResource', $media, "media msute of type MediaResource"); |
221 ); |
152 ); |
222 } |
153 } |
223 } |
154 } |
224 |
155 |
225 public function testGetDiscourseTypes() { |
156 public function testGetDiscourseTypes() { |
226 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
157 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
227 |
158 |
228 $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3"); |
159 $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3"); |
229 |
160 |
230 $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $doc->getDiscourseTypes(), "Result contains only literals"); |
161 $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $doc->getDiscourseTypes(), "Result contains only literals"); |
231 $type = $doc->getDiscourseTypes()[0]; |
162 $type = $doc->getDiscourseTypes()[0]; |
232 $this->assertEquals("narrative", $type->getValue(), "discourse type is narrative"); |
163 $this->assertEquals("narrative", $type->getValue(), "discourse type is narrative"); |
233 $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $type->getDatatypeUri(), "discourse type url"); |
164 $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $type->getDatatypeUri(), "discourse type url"); |
234 } |
165 } |
235 |
166 |
236 public function testCloneDocument() { |
167 public function testCloneDocument() { |
237 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
168 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
238 |
169 |
239 $doc2 = clone $doc; |
170 $doc2 = clone $doc; |
240 |
171 |
241 $this->assertNotSame($doc, $doc2, "documents must not be the same"); |
172 $this->assertNotSame($doc, $doc2, "documents must not be the same"); |
242 $this->assertNotSame($doc->getGraph(), $doc2->getGraph(), "documents must not be the same"); |
173 $this->assertNotSame($doc->getGraph(), $doc2->getGraph(), "documents must not be the same"); |
243 |
174 |
244 $this->assertTrue(EasyRdf\Isomorphic::isomorphic($doc->getGraph(), $doc2->getGraph()),"graph must be isomorphic"); |
175 $this->assertTrue(EasyRdf\Isomorphic::isomorphic($doc->getGraph(), $doc2->getGraph()),"graph must be isomorphic"); |
245 } |
176 } |
246 |
177 |
247 public function testIsIsomorphic() { |
178 public function testIsIsomorphic() { |
248 $doc1 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph); |
179 $doc1 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
249 $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')))); |
180 $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(file_get_contents(DocumentTest::TEST_INPUT_DOCS['TEST']) , config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme')))); |
250 |
181 |
251 $this->assertTrue($doc1->isIsomorphic($doc2),"document must be isomorphic"); |
182 $this->assertTrue($doc1->isIsomorphic($doc2),"document must be isomorphic"); |
252 |
183 |
253 $doc2->addLiteral('dc11:type', new EasyRdf\Literal("oratory", null, Config::get('OLAC_DISCOURSE_TYPE')['uri'])); |
184 $doc2->addLiteral('dc11:type', new EasyRdf\Literal("oratory", null, Config::get('OLAC_DISCOURSE_TYPE')['uri'])); |
254 |
185 |
504 $this->assertTrue(is_array($json['transcript'])); |
435 $this->assertTrue(is_array($json['transcript'])); |
505 $this->assertTrue(is_array($json['mediaArray'])); |
436 $this->assertTrue(is_array($json['mediaArray'])); |
506 |
437 |
507 } |
438 } |
508 |
439 |
|
440 public function testAddGeoInfo() { |
|
441 |
|
442 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_GEOINFO']); |
|
443 //$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
|
444 |
|
445 $res = $doc->addGeoInfo(); |
|
446 $res->commit(); |
|
447 |
|
448 $this->assertNotNull($res, "A new georesource object must have been created"); |
|
449 |
|
450 $this->assertInstanceOf('CorpusParole\Models\GeoResource', $res, "the object created must be a geo resource"); |
|
451 |
|
452 $allSpatials = $doc->getProvidedCHO()->allResources("<http://purl.org/dc/terms/spatial>"); |
|
453 |
|
454 $this->assertCount(1, $allSpatials, "Must have only one spatial node"); |
|
455 |
|
456 $spatial = $allSpatials[0]; |
|
457 |
|
458 $this->assertTrue($spatial->isBNode(), "Spatial node must be a blank node"); |
|
459 $this->assertEquals($spatial->typeAsResource(), "http://www.europeana.eu/schemas/edm/Place", "type must be a http://www.europeana.eu/schemas/edm/Place"); |
|
460 |
|
461 $this->assertTrue($doc->isDirty(), "Document must be dirty"); |
|
462 $this->assertEquals(1, $doc->deltaCount(), "Must have only one delta."); |
|
463 |
|
464 $this->assertNotNull($res->getCurrentDelta(), "CurrentDelta is not null"); |
|
465 $this->assertTrue($res->getCurrentDelta()->getDeletedGraph()->isEmpty(), "deleted graph must be empty"); |
|
466 $this->assertEmpty($res->getCurrentDelta()->getDeleteWhere(), "Delete where must be empty"); |
|
467 $this->assertNotNull($res->getCurrentDelta()->getAddedGraph(), "Added graph is not null"); |
|
468 $this->assertEquals(2, $res->getCurrentDelta()->getAddedGraph()->countTriples(), "Added graph must have 2 triples"); |
|
469 |
|
470 } |
|
471 |
|
472 |
|
473 public function testAddGeoInfoNotEmpty() { |
|
474 |
|
475 $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
|
476 |
|
477 $res = $doc->addGeoInfo(); |
|
478 $res->commit(); |
|
479 |
|
480 $this->assertNotNull($res, "A new georesource object must have been created"); |
|
481 |
|
482 $this->assertInstanceOf('CorpusParole\Models\GeoResource', $res, "the object created must be a geo resource"); |
|
483 |
|
484 $allSpatials = $doc->getProvidedCHO()->allResources("<http://purl.org/dc/terms/spatial>"); |
|
485 |
|
486 $this->assertCount(1, $allSpatials, "Must have only one spatial node"); |
|
487 |
|
488 $spatial = $allSpatials[0]; |
|
489 |
|
490 $this->assertTrue($spatial->isBNode(), "Spatial node must be a blank node"); |
|
491 $this->assertEquals($spatial->typeAsResource(), "http://www.europeana.eu/schemas/edm/Place", "type must be a http://www.europeana.eu/schemas/edm/Place"); |
|
492 |
|
493 $this->assertTrue($doc->isDirty(), "Document must not be dirty"); |
|
494 $this->assertEquals(1, $doc->deltaCount(), "Must have only one delta."); |
|
495 |
|
496 $this->assertNotNull($res->getCurrentDelta(), "CurrentDelta is not null"); |
|
497 $this->assertTrue($res->getCurrentDelta()->getDeletedGraph()->isEmpty(), "deleted graph must be empty"); |
|
498 $this->assertCount(1, $res->getCurrentDelta()->getDeleteWhere(), "Delete where must have one element"); |
|
499 $this->assertNotNull($res->getCurrentDelta()->getAddedGraph(), "Added graph is not null"); |
|
500 $this->assertEquals(9, $res->getCurrentDelta()->getAddedGraph()->countTriples(), "Added graph must have 7 triples"); |
|
501 } |
|
502 |
509 |
503 |
510 } |
504 } |