|
1 <?php |
|
2 |
|
3 use CorpusParole\Models\WebResource; |
|
4 use CorpusParole\Libraries\CocoonUtils; |
|
5 |
|
6 use Mockery as m; |
|
7 |
|
8 /** |
|
9 * |
|
10 */ |
|
11 class WebResourceTest extends TestCase { |
|
12 |
|
13 const TEST_DOCS = [ |
|
14 'http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml' => <<<EOT |
|
15 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
|
16 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
|
17 @prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
|
18 @prefix owl: <http://www.w3.org/2002/07/owl#> . |
|
19 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
|
20 @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
|
21 |
|
22 <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> ; |
|
23 <http://purl.org/dc/elements/1.1/format> "application/xml"^^<http://purl.org/dc/terms/IMT> ; |
|
24 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
25 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
26 <http://purl.org/dc/terms/issued> "2013-11-04T22:20:07+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
27 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
28 <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber> . |
|
29 |
|
30 EOT |
|
31 ,'http://cocoon.huma-num.fr/data/archi/masters/372593.wav' => <<<EOT |
|
32 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
|
33 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
|
34 @prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
|
35 @prefix owl: <http://www.w3.org/2002/07/owl#> . |
|
36 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
|
37 @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
|
38 |
|
39 <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
40 <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
|
41 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
42 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
43 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
44 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
45 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> . |
|
46 EOT |
|
47 ,"http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3" => <<<EOT |
|
48 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
|
49 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
|
50 @prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
|
51 @prefix owl: <http://www.w3.org/2002/07/owl#> . |
|
52 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
|
53 @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
|
54 |
|
55 <%1\$scrdo-CFPP2000_35_SOUND> a <http://www.openarchives.org/ore/terms/Aggregation> ; |
|
56 <http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> ; |
|
57 <http://www.europeana.eu/schemas/edm/dataProvider> "Langage et langues : description, théorisation, transmission" ; |
|
58 <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> ; |
|
59 <http://www.europeana.eu/schemas/edm/isShownAt> <http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-CFPP2000_35_SOUND> ; |
|
60 <http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> ; |
|
61 <http://www.europeana.eu/schemas/edm/provider> "Corpus de la Parole"@fr ; |
|
62 <http://www.europeana.eu/schemas/edm/rights> <http://creativecommons.org/licenses/by-nc-sa/4.0/> . |
|
63 |
|
64 <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ; |
|
65 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
66 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
67 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
68 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
69 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
70 <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" ; |
|
71 <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 ; |
|
72 <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" ; |
|
73 <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ; |
|
74 <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/142432638>; |
|
75 <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> ; |
|
76 <http://purl.org/dc/elements/1.1/title> "Entretien de Ozgur Kiliç 2"@fr ; |
|
77 <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> ; |
|
78 <http://purl.org/dc/terms/available> "2013-10-12"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
79 <http://purl.org/dc/terms/spatial> [ |
|
80 a <http://www.europeana.eu/schemas/edm/Place> ; |
|
81 owl:sameAs <http://sws.geonames.org/6618626/> ; |
|
82 <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 |
|
83 ]; |
|
84 <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> ; |
|
85 <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/93752300> ; |
|
86 <http://www.language-archives.org/OLAC/1.1/interviewer> <http://viaf.org/viaf/93752300> ; |
|
87 <http://www.language-archives.org/OLAC/1.1/transcriber> "Tanguy, Noalig" ; |
|
88 <http://purl.org/dc/elements/1.1/coverage> "Quartier concerné : 3e"@fr ; |
|
89 <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" ; |
|
90 <http://purl.org/dc/elements/1.1/relation> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_31_SOUND> . |
|
91 |
|
92 |
|
93 <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> ; |
|
94 <http://purl.org/dc/elements/1.1/format> "application/xml"^^<http://purl.org/dc/terms/IMT> ; |
|
95 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
96 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
97 <http://purl.org/dc/terms/issued> "2013-11-04T22:20:07+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
98 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
99 <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber> . |
|
100 |
|
101 <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
102 <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
|
103 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
104 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
105 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
106 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
107 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> . |
|
108 |
|
109 <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
110 <http://purl.org/dc/elements/1.1/format> "audio/mpeg"^^<http://purl.org/dc/terms/IMT> ; |
|
111 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
112 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
113 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
114 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
115 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
116 <http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> . |
|
117 |
|
118 <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
|
119 <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
|
120 <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
|
121 <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
122 <http://purl.org/dc/terms/extent> "PT48M26S" ; |
|
123 <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
124 <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ; |
|
125 <http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> . |
|
126 EOT |
|
127 ]; |
|
128 |
|
129 public function getMockWebResource(...$contructorArgs) { |
|
130 return m::mock("CorpusParole\Models\WebResource", $contructorArgs) |
|
131 ->makePartial() |
|
132 ->shouldAllowMockingProtectedMethods() |
|
133 ->shouldReceive('jsonSerializeExtra') |
|
134 ->andReturn(['extra' => 'fields']) |
|
135 ->shouldReceive('doClearMemoizationCache'); |
|
136 |
|
137 } |
|
138 |
|
139 |
|
140 public function setUp() { |
|
141 |
|
142 parent::setup(); |
|
143 $this->graphs = []; |
|
144 foreach(self::TEST_DOCS as $uri => $ttl) { |
|
145 $this->graphs[$uri] = new EasyRdf\Graph($uri, sprintf($ttl, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))); |
|
146 } |
|
147 } |
|
148 |
|
149 public function testConstructor() { |
|
150 |
|
151 $this->assertNotNull($this->graphs, 'Graphs shoud not be null'); |
|
152 |
|
153 $webResource = $this->getMockWebResource('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'])->getMock(); |
|
154 |
|
155 $this->assertNotNull($webResource); |
|
156 } |
|
157 |
|
158 public function testUrl() { |
|
159 $webResource = $this->getMockWebResource('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'])->getMock(); |
|
160 $this->assertEquals('http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml', $webResource->getUrl(), 'URL should be http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml'); |
|
161 } |
|
162 |
|
163 public function testGetFormat() { |
|
164 $webResource = $this->getMockWebResource('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'])->getMock(); |
|
165 $this->assertEquals("application/xml", $webResource->getFormat(), "Format should be application/xml"); |
|
166 } |
|
167 |
|
168 public function testJsonSerialize() { |
|
169 $webResource = $this->getMockWebResource('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'])->getMock(); |
|
170 |
|
171 $json = $webResource->jsonSerialize(); |
|
172 $this->assertTrue(is_array($json), "must be an array"); |
|
173 $this->assertEquals( |
|
174 [ |
|
175 'url' => "http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml", |
|
176 "format" => "application/xml", |
|
177 "extra" => "fields" |
|
178 ], |
|
179 $json |
|
180 ); |
|
181 } |
|
182 |
|
183 public function testJsonSerializeFullDoc() { |
|
184 $webResource = $this->getMockWebResource("http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3", $this->graphs["http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3"])->getMock(); |
|
185 |
|
186 $json = $webResource->jsonSerialize(); |
|
187 $this->assertTrue(is_array($json), "must be an array"); |
|
188 $this->assertEquals( |
|
189 [ |
|
190 'url' => "http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3", |
|
191 "format" => "audio/mpeg", |
|
192 "extra" => "fields" |
|
193 ], |
|
194 $json |
|
195 ); |
|
196 } |
|
197 |
|
198 public function tearDown() { |
|
199 m::close(); |
|
200 } |
|
201 |
|
202 } |