|
1 <?php |
|
2 |
|
3 use CorpusParole\Models\TranscriptResource; |
|
4 use CorpusParole\Libraries\CocoonUtils; |
|
5 |
|
6 /** |
|
7 * |
|
8 */ |
|
9 class TranscriptResourceTest extends TestCase { |
|
10 |
|
11 const TEST_DOCS = [ |
|
12 'http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml' => <<<EOT |
|
13 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
|
14 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
|
15 @prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
|
16 @prefix owl: <http://www.w3.org/2002/07/owl#> . |
|
17 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
|
18 @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
|
19 |
|
20 <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> ; |
|
21 <http://purl.org/dc/elements/1.1/format> "application/xml"^^<http://purl.org/dc/terms/IMT> ; |
|
22 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
23 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
24 <http://purl.org/dc/terms/issued> "2013-11-04T22:20:07+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
25 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
26 <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber> . |
|
27 |
|
28 EOT |
|
29 ,'http://cocoon.huma-num.fr/data/archi/masters/372593.wav' => <<<EOT |
|
30 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
|
31 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
|
32 @prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
|
33 @prefix owl: <http://www.w3.org/2002/07/owl#> . |
|
34 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
|
35 @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
|
36 |
|
37 <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
38 <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
|
39 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
40 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
41 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
42 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
43 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> . |
|
44 EOT |
|
45 ]; |
|
46 |
|
47 public function setUp() { |
|
48 |
|
49 parent::setup(); |
|
50 $this->graphs = []; |
|
51 foreach(self::TEST_DOCS as $uri => $ttl) { |
|
52 $this->graphs[$uri] = new EasyRdf\Graph($uri, $ttl); |
|
53 } |
|
54 } |
|
55 |
|
56 public function testConstructor() { |
|
57 |
|
58 $this->assertNotNull($this->graphs, 'Graphs shoud not be null'); |
|
59 |
|
60 $transcriptResource = new TranscriptResource('http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml', $this->graphs['http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml']); |
|
61 |
|
62 $this->assertNotNull($transcriptResource); |
|
63 } |
|
64 |
|
65 public function testConformsTo() { |
|
66 $transcriptResource = new TranscriptResource('http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml', $this->graphs['http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml']); |
|
67 $this->assertEquals('http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber', $transcriptResource->getConformsTo()); |
|
68 } |
|
69 |
|
70 public function testJsonSerialize() { |
|
71 $transcriptResource = new TranscriptResource('http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml', $this->graphs['http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml']); |
|
72 |
|
73 $json = $transcriptResource->jsonSerialize(); |
|
74 $this->assertTrue(is_array($json), "must be an array"); |
|
75 $this->assertEquals( |
|
76 [ |
|
77 'url' => "http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml", |
|
78 "format" => "application/xml", |
|
79 "conforms-to" => "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber" |
|
80 ], |
|
81 $json |
|
82 ); |
|
83 } |
|
84 |
|
85 } |