|
1 <?php |
|
2 |
|
3 use CorpusParole\Models\MediaResource; |
|
4 use CorpusParole\Libraries\CocoonUtils; |
|
5 |
|
6 /** |
|
7 * |
|
8 */ |
|
9 class MediaResourceTest 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 $mediaResource = new MediaResource('http://cocoon.huma-num.fr/data/archi/masters/372593.wav', $this->graphs['http://cocoon.huma-num.fr/data/archi/masters/372593.wav'], false); |
|
61 |
|
62 $this->assertNotNull($mediaResource); |
|
63 } |
|
64 |
|
65 public function testExtent() { |
|
66 $mediaResource = new MediaResource('http://cocoon.huma-num.fr/data/archi/masters/372593.wav', $this->graphs['http://cocoon.huma-num.fr/data/archi/masters/372593.wav'], false); |
|
67 $this->assertEquals('PT48M26S', $mediaResource->getExtent()); |
|
68 } |
|
69 |
|
70 public function testExtentMs() { |
|
71 $mediaResource = new MediaResource('http://cocoon.huma-num.fr/data/archi/masters/372593.wav', $this->graphs['http://cocoon.huma-num.fr/data/archi/masters/372593.wav'], false); |
|
72 $this->assertTrue(is_int($mediaResource->getExtentMs())); |
|
73 $this->assertEquals(2906000, $mediaResource->getExtentMs()); |
|
74 } |
|
75 |
|
76 public function testMaster() { |
|
77 $mediaResource = new MediaResource('http://cocoon.huma-num.fr/data/archi/masters/372593.wav', $this->graphs['http://cocoon.huma-num.fr/data/archi/masters/372593.wav'], true); |
|
78 $this->assertTrue($mediaResource->isMaster()); |
|
79 } |
|
80 |
|
81 public function testJsonSerialize() { |
|
82 $mediaResource = new MediaResource('http://cocoon.huma-num.fr/data/archi/masters/372593.wav', $this->graphs['http://cocoon.huma-num.fr/data/archi/masters/372593.wav'], true); |
|
83 |
|
84 $json = $mediaResource->jsonSerialize(); |
|
85 $this->assertTrue(is_array($json), "must be an array"); |
|
86 $this->assertEquals( |
|
87 [ |
|
88 'url' => "http://cocoon.huma-num.fr/data/archi/masters/372593.wav", |
|
89 "format" => "audio/x-wav", |
|
90 "extent" => "PT48M26S", |
|
91 "extent_ms" => 2906000, |
|
92 "master" => true |
|
93 ], |
|
94 $json |
|
95 ); |
|
96 } |
|
97 |
|
98 } |