123 parent::__construct($name); |
122 parent::__construct($name); |
124 } |
123 } |
125 |
124 |
126 public function setUp() { |
125 public function setUp() { |
127 parent::setUp(); |
126 parent::setUp(); |
|
127 |
|
128 $this->testGraphUri = config('corpusparole.corpus_doc_id_base_uri').CocoonSoundRdfMapperTest::TEST_INPUT_ID; |
128 |
129 |
129 foreach(CocoonSoundRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) { |
130 foreach(CocoonSoundRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) { |
130 $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019", $inputDoc); |
131 $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019", $inputDoc); |
131 $this->mappers[$key] = new CocoonSoundRdfMapper($this->inputGraphes[$key]); |
132 $this->mappers[$key] = new CocoonSoundRdfMapper($this->inputGraphes[$key]); |
132 $this->mappers[$key]->mapGraph(); |
133 $this->mappers[$key]->mapGraph(); |
157 |
158 |
158 //echo $this->resGraphes['BASE']->serialise('turtle'); |
159 //echo $this->resGraphes['BASE']->serialise('turtle'); |
159 //echo var_export($this->resGraphes['BASE']->toRdfPhp()); |
160 //echo var_export($this->resGraphes['BASE']->toRdfPhp()); |
160 |
161 |
161 $this->assertNotNull($this->resGraphes['BASE']); |
162 $this->assertNotNull($this->resGraphes['BASE']); |
162 $this->assertEquals(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, $this->resGraphes['BASE']->getUri(), "URIS must be translated"); |
163 $this->assertEquals($this->testGraphUri, $this->resGraphes['BASE']->getUri(), "URIS must be translated"); |
163 } |
164 } |
164 |
165 |
165 /** |
166 /** |
166 * Test that the return graph has one ore:Aggregation resource |
167 * Test that the return graph has one ore:Aggregation resource |
167 * |
168 * |
170 public function testAggregationResource() { |
171 public function testAggregationResource() { |
171 |
172 |
172 $resources = $this->resGraphes['BASE']->allOfType('ore:Aggregation'); |
173 $resources = $this->resGraphes['BASE']->allOfType('ore:Aggregation'); |
173 |
174 |
174 $this->assertCount(1, $resources, "Must found only one resources of type ore:Aggregation"); |
175 $this->assertCount(1, $resources, "Must found only one resources of type ore:Aggregation"); |
175 $this->assertEquals(CocoonSoundRdfMapperTest::TEST_GRAPH_URI,$resources[0]); |
176 $this->assertEquals($this->testGraphUri,$resources[0]); |
176 } |
177 } |
177 |
178 |
178 /** |
179 /** |
179 * test that there one (and only one) edm:dateProvider and edm:provider property |
180 * test that there one (and only one) edm:dateProvider and edm:provider property |
180 * |
181 * |
181 * @return void |
182 * @return void |
182 */ |
183 */ |
183 public function testProviders() { |
184 public function testProviders() { |
184 |
185 |
185 $providers = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI,'edm:provider'); |
186 $providers = $this->resGraphes['BASE']->all($this->testGraphUri,'edm:provider'); |
186 |
187 |
187 $this->assertCount(1,$providers, "one and only one edm provider"); |
188 $this->assertCount(1,$providers, "one and only one edm provider"); |
188 $this->assertTrue($providers[0] instanceof Literal); |
189 $this->assertTrue($providers[0] instanceof Literal); |
189 $this->assertEquals('Corpus de la Parole', $providers[0]->getValue(), 'provider must be Corpus de la Parole'); |
190 $this->assertEquals('Corpus de la Parole', $providers[0]->getValue(), 'provider must be Corpus de la Parole'); |
190 $this->assertEquals('fr', $providers[0]->getLang(), 'provider must be in french'); |
191 $this->assertEquals('fr', $providers[0]->getLang(), 'provider must be in french'); |
191 |
192 |
192 $dataProviders = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI,'edm:dataProvider'); |
193 $dataProviders = $this->resGraphes['BASE']->all($this->testGraphUri,'edm:dataProvider'); |
193 |
194 |
194 $this->assertCount(1,$dataProviders, "one and only one edm data provider"); |
195 $this->assertCount(1,$dataProviders, "one and only one edm data provider"); |
195 //TODO: to change after viaf resolution |
196 //TODO: to change after viaf resolution |
196 $this->assertTrue($dataProviders[0] instanceof Resource); |
197 $this->assertTrue($dataProviders[0] instanceof Resource); |
197 $this->assertEquals('http://viaf.org/viaf/181558906', $dataProviders[0]->getUri(), 'dataProvider uri must be http://viaf.org/viaf/181558906'); |
198 $this->assertEquals('http://viaf.org/viaf/181558906', $dataProviders[0]->getUri(), 'dataProvider uri must be http://viaf.org/viaf/181558906'); |
203 * |
204 * |
204 * @return void |
205 * @return void |
205 */ |
206 */ |
206 public function testIsShown() { |
207 public function testIsShown() { |
207 |
208 |
208 $isShownAts = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, 'edm:isShownAt'); |
209 $isShownAts = $this->resGraphes['BASE']->all($this->testGraphUri, 'edm:isShownAt'); |
209 |
210 |
210 $this->assertCount(1, $isShownAts, "One edm:isShownAt"); |
211 $this->assertCount(1, $isShownAts, "One edm:isShownAt"); |
211 $this->assertInstanceOf("EasyRdf\Resource", $isShownAts[0]); |
212 $this->assertInstanceOf("EasyRdf\Resource", $isShownAts[0]); |
212 $this->assertEquals("http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-ESLO1_ENT_019", $isShownAts[0]); |
213 $this->assertEquals("http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-ESLO1_ENT_019", $isShownAts[0]); |
213 |
214 |
214 $isShownBys = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, 'edm:isShownBy'); |
215 $isShownBys = $this->resGraphes['BASE']->all($this->testGraphUri, 'edm:isShownBy'); |
215 |
216 |
216 $this->assertCount(1, $isShownBys, "One edm:isShownBy"); |
217 $this->assertCount(1, $isShownBys, "One edm:isShownBy"); |
217 $this->assertInstanceOf("EasyRdf\Resource", $isShownBys[0]); |
218 $this->assertInstanceOf("EasyRdf\Resource", $isShownBys[0]); |
218 $this->assertEquals("http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav", $isShownBys[0]); |
219 $this->assertEquals("http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav", $isShownBys[0]); |
219 |
220 |
223 * test rights |
224 * test rights |
224 * |
225 * |
225 * @return void |
226 * @return void |
226 */ |
227 */ |
227 public function testRights() { |
228 public function testRights() { |
228 $rightsNodes = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, 'edm:rights'); |
229 $rightsNodes = $this->resGraphes['BASE']->all($this->testGraphUri, 'edm:rights'); |
229 |
230 |
230 $this->assertCount(1, $rightsNodes, "One edm:right"); |
231 $this->assertCount(1, $rightsNodes, "One edm:right"); |
231 |
232 |
232 $rights = $rightsNodes[0]; |
233 $rights = $rightsNodes[0]; |
233 |
234 |
500 |
501 |
501 $resources = $this->resGraphes['BASE']->allOfType('edm:WebResource'); |
502 $resources = $this->resGraphes['BASE']->allOfType('edm:WebResource'); |
502 |
503 |
503 $this->assertCount(3, $resources, "Must found three webresource"); |
504 $this->assertCount(3, $resources, "Must found three webresource"); |
504 |
505 |
505 $aggregation = $this->resGraphes['BASE']->resource(CocoonSoundRdfMapperTest::TEST_GRAPH_URI); |
506 $aggregation = $this->resGraphes['BASE']->resource($this->testGraphUri); |
506 |
507 |
507 foreach ($resources as $wres) { |
508 foreach ($resources as $wres) { |
508 $mimetypes = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/format')); |
509 $mimetypes = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/format')); |
509 $this->assertCount(1, $mimetypes, "Must find one mimetype."); |
510 $this->assertCount(1, $mimetypes, "Must find one mimetype."); |
510 $mimetype = $mimetypes[0]; |
511 $mimetype = $mimetypes[0]; |
567 */ |
568 */ |
568 public function testCollectionGraph() { |
569 public function testCollectionGraph() { |
569 $outputs = $this->mappers['BASE']->getOutputGraphes(); |
570 $outputs = $this->mappers['BASE']->getOutputGraphes(); |
570 $this->assertCount(3, $outputs, "Must have 3 graphes as output"); |
571 $this->assertCount(3, $outputs, "Must have 3 graphes as output"); |
571 foreach($outputs as $url => $outputGraph) { |
572 foreach($outputs as $url => $outputGraph) { |
572 if($outputGraph->getUri() == 'http://corpusdelaparole.huma-num.fr/corpus/res/crdo-ESLO1_ENT_019') { |
573 if($outputGraph->getUri() == config('corpusparole.corpus_doc_id_base_uri').'crdo-ESLO1_ENT_019') { |
573 continue; |
574 continue; |
574 } |
575 } |
575 $this->assertContains($outputGraph->getUri(), ['http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE', 'http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1']); |
576 $this->assertContains($outputGraph->getUri(), ['http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE', 'http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1']); |
576 $this->assertEquals($outputGraph->resource($outputGraph->getUri())->type(), 'edm:Collection'); |
577 $this->assertEquals($outputGraph->resource($outputGraph->getUri())->type(), 'edm:Collection'); |
577 } |
578 } |