diff -r 009efee954f7 -r 17f10b56c079 server/src/tests/Models/TranscriptResourceTest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/tests/Models/TranscriptResourceTest.php Thu Jun 02 18:24:19 2016 +0200 @@ -0,0 +1,85 @@ + << . + @prefix rdfs: . + @prefix sesame: . + @prefix owl: . + @prefix xsd: . + @prefix fn: . + + a ; + "application/xml"^^ ; + "Freely available for non-commercial use" ; + "2010-11-17"^^ ; + "2013-11-04T22:20:07+01:00"^^ ; + ; + . + +EOT + ,'http://cocoon.huma-num.fr/data/archi/masters/372593.wav' => << . + @prefix rdfs: . + @prefix sesame: . + @prefix owl: . + @prefix xsd: . + @prefix fn: . + + a ; + "audio/x-wav"^^ ; + "Freely available for non-commercial use" ; + "2010-11-17"^^ ; + "PT48M26S" ; + "2013-10-12T14:35:57+02:00"^^ ; + . +EOT + ]; + + public function setUp() { + + parent::setup(); + $this->graphs = []; + foreach(self::TEST_DOCS as $uri => $ttl) { + $this->graphs[$uri] = new EasyRdf\Graph($uri, $ttl); + } + } + + public function testConstructor() { + + $this->assertNotNull($this->graphs, 'Graphs shoud not be null'); + + $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']); + + $this->assertNotNull($transcriptResource); + } + + public function testConformsTo() { + $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']); + $this->assertEquals('http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber', $transcriptResource->getConformsTo()); + } + + public function testJsonSerialize() { + $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']); + + $json = $transcriptResource->jsonSerialize(); + $this->assertTrue(is_array($json), "must be an array"); + $this->assertEquals( + [ + 'url' => "http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml", + "format" => "application/xml", + "conforms-to" => "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber" + ], + $json + ); + } + +}