author | ymh <ymh.work@gmail.com> |
Mon, 06 Feb 2017 15:22:39 +0100 | |
changeset 500 | 4f507ba2bb4c |
parent 498 | 265992e5b379 |
child 501 | 7b2dcd2b31c1 |
permissions | -rw-r--r-- |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
use CorpusParole\Models\Document; |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4 |
use CorpusParole\Libraries\CocoonUtils; |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
6 |
use EasyRdf\RdfNamespace; |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
7 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
/** |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
* |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
*/ |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
class DocumentTest extends TestCase { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
13 |
const TEST_INPUT_DOCS = [ |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
14 |
'TEST' => __DIR__.'/files/DocumentTest/test_doc.ttl', |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
15 |
'TEST_NO_GEOINFO' => __DIR__.'/files/DocumentTest/test_no_geoinfo.ttl', |
498
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
16 |
'TEST_NO_DESCRIPTION' => __DIR__.'/files/DocumentTest/test_doc_no_description.ttl', |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
17 |
]; |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
18 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
19 |
private $inputGraphes = []; |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
public function setUp() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
22 |
parent::setup(); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
24 |
foreach(self::TEST_INPUT_DOCS as $key => $inputDoc) { |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
25 |
$this->inputGraphes[$key] = new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(file_get_contents($inputDoc), config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
26 |
} |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
27 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
public function testConstructor() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
32 |
$this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
34 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
|
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
138
diff
changeset
|
36 |
$this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id'); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
public function testTitle() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
40 |
$this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
42 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
|
130
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
44 |
$this->assertEquals("Entretien de Ozgur KiliƧ 2",$doc->getTitle(),'Must have correct title'); |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
45 |
$this->assertInstanceOf(EasyRdf\Literal::class, $doc->getTitle(), "Title must be a literal"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
$this->assertEquals('fr', $doc->getTitle()->getLang(), "Language title must be fr"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
49 |
|
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
public function testModified() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
51 |
$this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null'); |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
52 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
53 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
54 |
$this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
55 |
$this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
56 |
$this->assertEquals("2013-10-12T14:35:57+02:00", $doc->getModified(), "modified must be 2013-10-12T14:35:57+02:00"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
57 |
|
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
58 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
60 |
public function testSetModified() { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
61 |
$currentTime = gmdate(DateTime::ATOM); |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
62 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
63 |
$doc->setModified($currentTime); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
64 |
$this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
65 |
$this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
66 |
$this->assertEquals(preg_replace('/[\+\-]00(\:?)00$/', 'Z', $currentTime), $doc->getModified()->getValue(), "modified must be $currentTime"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
67 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
68 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
69 |
public function testSetModifiedNull() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
70 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
71 |
$doc->setModified(); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
72 |
$this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
73 |
$this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
74 |
$foundDateTime = \DateTime::createFromFormat(\DateTime::ATOM, $doc->getModified()->getValue()); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
75 |
$nowUTC = new \DateTime('now', new \DateTimeZone("UTC")); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
76 |
$this->assertTrue($nowUTC->getTimestamp() - $foundDateTime->getTimestamp() < 2, "must have less than 2 seconds diff"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
77 |
} |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
78 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
public function testPublisher() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
81 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
$this->assertCount(1, $doc->getPublishers(), 'Publisher is an array of size 1'); |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
84 |
$this->assertInstanceOf('EasyRdf\Resource', $doc->getPublishers()[0], 'publisher is a resource'); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
85 |
$this->assertEquals("http://viaf.org/viaf/142432638", $doc->getPublishers()[0]->getUri(),""); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
public function testMediaArray() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
89 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
|
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
91 |
$this->assertCount(3, $doc->getMediaArray(), "Media array must be of size 3"); |
130
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
92 |
//print_r($doc->getMediaArray()); |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
93 |
foreach($doc->getMediaArray() as $media) { |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
94 |
$this->assertInstanceOf('CorpusParole\Models\MediaResource', $media, "media msute of type MediaResource"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
95 |
// $this->assertArrayHasKey('format', $media, "media has 'format key'"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
96 |
// $this->assertArrayHasKey('url', $media, "media has url"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
97 |
// $this->assertCount(5, $media, "media is a 4 element array"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
98 |
// $this->assertArrayHasKey('extent', $media, "media has extent"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
99 |
// $this->assertArrayHasKey('extent_ms', $media, "media has extent_ms"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
100 |
// $this->assertArrayHasKey('master', $media, "media has master"); |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
101 |
|
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
102 |
//$this->assertEquals($media['url'], $url); |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
103 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
104 |
$this->assertContains( |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
105 |
$media->getUrl(), |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
106 |
[ "http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav", |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
107 |
"http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3", |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
108 |
"http://cocoon.huma-num.fr/data/archi/masters/372593.wav" |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
109 |
] |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
110 |
); |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
111 |
if($media->getUrl() === "http://cocoon.huma-num.fr/data/archi/masters/372593.wav") { |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
112 |
$this->assertEquals('audio/x-wav', $media->getFormat()); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
113 |
$this->assertTrue($media->isMaster() === true, "should be master"); |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
114 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
115 |
else { |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
116 |
$this->assertTrue($media->isMaster() === false, "should not be master"); |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
117 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
118 |
|
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
119 |
$this->assertEquals("PT48M26S", $media->getExtent(), "extent is PT48M26S"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
120 |
$this->assertGreaterThan(0, $media->getExtentMs(), "extent_ms must be > 0"); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
121 |
$this->assertStringStartsWith('audio/', $media->getFormat()); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
public function testGetTypes() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
126 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
|
130
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
128 |
$this->assertCount(8, $doc->getTypes(), "types array must be of size 5"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
foreach($doc->getTypes() as $type) { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
$this->assertThat( |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
$type, |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
$this->logicalXor( |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
134 |
$this->isInstanceOf(EasyRdf\Literal::class), |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
135 |
$this->isInstanceOf(EasyRdf\Resource::class) |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
) |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
139 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
public function testGetOtherTypes() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
142 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
143 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
144 |
$this->assertCount(6, $doc->getOtherTypes(), "types array must be of size 5"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
foreach($doc->getTypes() as $type) { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
$this->assertThat( |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
$type, |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
$this->logicalXor( |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
150 |
$this->isInstanceOf(EasyRdf\Literal::class), |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
151 |
$this->isInstanceOf(EasyRdf\Resource::class) |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
) |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
public function testGetDiscourseTypes() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
158 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
160 |
$this->assertCount(2, $doc->getDiscourseTypes(), "types array must be of size 3"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
162 |
$this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $doc->getDiscourseTypes(), "Result contains only Resources"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
$type = $doc->getDiscourseTypes()[0]; |
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
164 |
$this->assertEquals("http://ark.bnf.fr/ark:/12148/cb11932135w", $type->getUri(), "discourse type is cb11932135w"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
public function testCloneDocument() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
168 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
$doc2 = clone $doc; |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
171 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
172 |
$this->assertNotSame($doc, $doc2, "documents must not be the same"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
$this->assertNotSame($doc->getGraph(), $doc2->getGraph(), "documents must not be the same"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
|
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
175 |
$this->assertTrue(EasyRdf\Isomorphic::isomorphic($doc->getGraph(), $doc2->getGraph()),"graph must be isomorphic"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
176 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
public function testIsIsomorphic() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
179 |
$doc1 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
180 |
$doc2 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(file_get_contents(DocumentTest::TEST_INPUT_DOCS['TEST']) , config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme')))); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
$this->assertTrue($doc1->isIsomorphic($doc2),"document must be isomorphic"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
|
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
184 |
$doc2->addLiteral('dc11:type', new EasyRdf\Literal("oratory", null, Config::get('OLAC_DISCOURSE_TYPE')['uri'])); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
$this->assertFalse($doc1->isIsomorphic($doc2),"document must not be isomorphic"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
public function testUpdateDiscourseTypes() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
191 |
$newDiscourseTypes = ["http://ark.bnf.fr/ark:/12148/cb11932135w" , "http://ark.bnf.fr/ark:/12148/cb13319048g", "http://ark.bnf.fr/ark:/12148/cb11949715t" , "http://ark.bnf.fr/ark:/12148/cb119783362"]; |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
193 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
194 |
$this->assertCount(2, $doc->getDiscourseTypes(), "types array must be of size 2"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
$doc->updateDiscourseTypes($newDiscourseTypes); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
198 |
$this->assertCount(4, $doc->getDiscourseTypes(), "types array must be of size 4"); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
$discourseTypes = $doc->getDiscourseTypes(); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
foreach($newDiscourseTypes as $dt) { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
$this->assertContains($dt, $discourseTypes, "all discourse types must be in result list"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
203 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
204 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
|
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
207 |
public function testUpdateDiscourseTypesDelta() { |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
208 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
209 |
$newDiscourseTypes = ["http://ark.bnf.fr/ark:/12148/cb11932135w" , "http://ark.bnf.fr/ark:/12148/cb13319048g", "http://ark.bnf.fr/ark:/12148/cb11949715t" , "http://ark.bnf.fr/ark:/12148/cb119783362"]; |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
210 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
211 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
212 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
213 |
$doc->updateDiscourseTypes($newDiscourseTypes); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
214 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
215 |
$this->assertTrue($doc->isDirty()); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
216 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
217 |
$this->assertEquals(1, $doc->deltaCount(), "There is one delta"); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
218 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
219 |
$delta = $doc->getDeltaList()[0]; |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
220 |
|
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
138
diff
changeset
|
221 |
$this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $delta->getDeletedGraph()->getUri(), "uri of deleted graph must be ok"); |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
138
diff
changeset
|
222 |
$this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $delta->getAddedGraph()->getUri(), "uri of added graph must be ok"); |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
223 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
224 |
$this->assertEquals(2, $delta->getDeletedGraph()->countTriples(), "deleted graph must have only 2 triples"); |
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
225 |
$this->assertEquals(4, $delta->getAddedGraph()->countTriples(), "deleted graph must have only 4 triples"); |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
226 |
|
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
227 |
$resQueryDiscourseType = $delta->getAddedGraph()->allResources($doc->getProvidedCHO(), 'dc11:type'); |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
228 |
foreach($resQueryDiscourseType as $dt) { |
371
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
229 |
$this->assertInstanceOf(EasyRdf\Resource::class, $dt, "This must be a Resource"); |
0365fd9977a4
Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
230 |
$this->assertRegexp(config('corpusparole.bnf_ark_url_regexp'), $dt->getUri(), "The resource uri must be bnf ark"); |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
231 |
} |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
232 |
foreach($newDiscourseTypes as $dt) { |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
233 |
$this->assertContains($dt, $resQueryDiscourseType, "all discourse types must be in result list"); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
234 |
} |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
235 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
236 |
} |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
237 |
|
28 | 238 |
public function testUpdateTitle() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
239 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
28 | 240 |
|
241 |
$oldTitle = $doc->getTitle(); |
|
242 |
||
243 |
$doc->setTitle("new title", "en"); |
|
244 |
||
245 |
$this->assertEquals("new title", $doc->getTitleValue()); |
|
246 |
$this->assertEquals("new title", $doc->getTitle()->getValue()); |
|
247 |
$this->assertEquals("en", $doc->getTitle()->getLang()); |
|
248 |
||
249 |
$this->assertTrue($doc->isDirty()); |
|
250 |
$this->assertEquals(1, $doc->deltaCount(), "There is one delta"); |
|
251 |
||
252 |
$delta = $doc->getDeltaList()[0]; |
|
253 |
||
254 |
$addedTitles = $delta->getAddedGraph()->allLiterals($doc->getProvidedCHO(), '<http://purl.org/dc/elements/1.1/title>'); |
|
255 |
$this->assertCount(1, $addedTitles); |
|
256 |
||
257 |
$removedTitles = $delta->getDeletedGraph()->allLiterals($doc->getProvidedCHO(), '<http://purl.org/dc/elements/1.1/title>'); |
|
258 |
$this->assertCount(1, $removedTitles); |
|
259 |
||
260 |
||
261 |
} |
|
262 |
||
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
263 |
public function testUpdateDiscourseTypesIsomorphic() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
264 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
265 |
$newDiscourseTypes = ['oratory','dialogue','narrative']; |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
266 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
267 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
268 |
$doc->updateDiscourseTypes($newDiscourseTypes); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
269 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
270 |
$doc2 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(file_get_contents(DocumentTest::TEST_INPUT_DOCS['TEST']), config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme')))); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
271 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
272 |
$this->assertFalse($doc->isIsomorphic($doc2),"document must not be isomorphic after adding discourse type"); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
273 |
} |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
274 |
|
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
275 |
public function testGetContributors() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
276 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
277 |
|
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
278 |
$contributors = $doc->getContributors(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
279 |
|
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
280 |
$this->assertNotEmpty($contributors, "The contributors array should not be empty"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
281 |
$this->assertCount(8, $contributors, "The contributors array should have 8 elements"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
282 |
|
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
283 |
foreach ($contributors as $contribDef) { |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
284 |
$this->assertArrayHasKey('name', $contribDef, "ContribDef must have name key"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
285 |
$this->assertArrayHasKey('url', $contribDef, "ContribDef must have url key"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
286 |
$this->assertArrayHasKey('role', $contribDef, "ContribDef must have role key"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
287 |
$this->assertContains($contribDef['role'], CocoonUtils::OLAC_ROLES, "Role should be in OLAC_ROLES"); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
288 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
289 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
290 |
|
28 | 291 |
public function testSetContributors() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
292 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
28 | 293 |
|
294 |
$contributors = $doc->getContributors(); |
|
295 |
||
296 |
$contribList = [[ |
|
297 |
"name"=> "Guylaine Brun-Trigaud", |
|
298 |
"url"=> "http://viaf.org/viaf/56666014", |
|
299 |
"role"=> "http://www.language-archives.org/OLAC/1.1/data_inputter" |
|
300 |
], [ |
|
301 |
"name"=> "LDOR", |
|
302 |
"url"=> null, |
|
303 |
"role"=> "http://www.language-archives.org/OLAC/1.1/depositor" |
|
304 |
], [ |
|
305 |
"name"=> "ThƩsaurus Occitan", |
|
306 |
"url"=> null, |
|
307 |
"role"=> "http://www.language-archives.org/OLAC/1.1/depositor" |
|
308 |
], [ |
|
309 |
"name"=> "Ćquipe de Recherche en Syntaxe et SĆ©mantique", |
|
310 |
"url"=> null, |
|
311 |
"role"=> "http://www.language-archives.org/OLAC/1.1/editor" |
|
312 |
], [ |
|
313 |
"name"=> "Bases, corpus, langage", |
|
314 |
"url"=> null, |
|
315 |
"role"=> "http://www.language-archives.org/OLAC/1.1/editor" |
|
316 |
], [ |
|
317 |
"name"=> "Patrick Sauzet", |
|
318 |
"url"=> "http://viaf.org/viaf/51700729", |
|
319 |
"role"=> "http://www.language-archives.org/OLAC/1.1/researcher" |
|
320 |
], [ |
|
321 |
"name"=> "Alazet, Pierre", |
|
322 |
"url"=> null, |
|
323 |
"role"=> "http://www.language-archives.org/OLAC/1.1/speaker" |
|
324 |
], [ |
|
325 |
"name"=> "Del Duca, Jeanne", |
|
326 |
"url"=> null, |
|
327 |
"role"=> "http://www.language-archives.org/OLAC/1.1/transcriber" |
|
328 |
], [ |
|
329 |
"name"=> "Jane Austen, 1775-1817", |
|
330 |
"url"=> "http://viaf.org/viaf/102333412", |
|
331 |
"role"=> "http://www.language-archives.org/OLAC/1.1/compiler" |
|
332 |
]]; |
|
333 |
||
334 |
$doc->setContributors($contribList); |
|
335 |
||
336 |
$newContribs = $doc->getContributors(); |
|
337 |
||
338 |
$this->assertCount(9, $newContribs); |
|
339 |
||
340 |
$this->assertTrue($doc->isDirty()); |
|
341 |
$this->assertEquals(1, $doc->deltaCount(), "There is one delta"); |
|
342 |
||
343 |
$delta = $doc->getDeltaList()[0]; |
|
344 |
||
345 |
$addedGraph = $delta->getAddedGraph(); |
|
346 |
$this->assertEquals(9, $addedGraph->countTriples()); |
|
347 |
||
348 |
$removedGraph = $delta->getDeletedGraph(); |
|
349 |
$this->assertEquals(count($contributors), $removedGraph->countTriples()); |
|
350 |
||
351 |
$foundJaneAusten = false; |
|
352 |
foreach ($newContribs as $contribDef) { |
|
353 |
if(!is_null($contribDef['nameLiteral'])) { |
|
354 |
$lit = $contribDef['nameLiteral']; |
|
355 |
$this->assertNull($lit->getDatatype(), "Data type must be null $lit"); |
|
356 |
$this->assertNotNull($lit->getLang(), "lang must not be null $lit"); |
|
357 |
} |
|
358 |
if($contribDef['url'] == 'http://viaf.org/viaf/102333412') { |
|
359 |
$this->assertNull($contribDef['name'], 'Name must be null'); |
|
360 |
$this->assertNull($contribDef['nameLiteral'], 'Name literal must be null'); |
|
361 |
$foundJaneAusten = true; |
|
362 |
} |
|
363 |
} |
|
497
f3474aeec884
add contry code in indexation, Serialize types, prepare #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
364 |
$this->assertTrue($foundJaneAusten, "Jane Austeen not foud"); |
28 | 365 |
|
366 |
} |
|
367 |
||
130
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
368 |
public function testGetSubjects() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
369 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
130
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
370 |
|
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
371 |
$subjects = $doc->getSubjects(); |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
372 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
373 |
$this->assertCount(28, $subjects, "Must have 28 subjects"); |
130
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
374 |
|
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
375 |
foreach ($doc->getSubjects() as $s) { |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
376 |
$this->assertThat( |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
377 |
$s, |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
378 |
$this->logicalXor( |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
379 |
$this->isInstanceOf('EasyRdf\Literal'), |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
380 |
$this->isInstanceOf('EasyRdf\Resource') |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
381 |
) |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
382 |
); |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
383 |
} |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
384 |
} |
fac22d8c2df8
add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
385 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
386 |
public function testSetSubjects() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
387 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
388 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
389 |
$newSubjects = [ |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
390 |
"http://ark.bnf.fr/ark:/12148/cb13318415c", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
391 |
"http://ark.bnf.fr/ark:/12148/cb133188907", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
392 |
"http://ark.bnf.fr/ark:/12148/cb11932762f", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
393 |
"http://ark.bnf.fr/ark:/12148/cb133183660", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
394 |
"http://ark.bnf.fr/ark:/12148/cb122368540", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
395 |
"http://ark.bnf.fr/ark:/12148/cb119418302", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
396 |
"http://ark.bnf.fr/ark:/12148/cb135540729", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
397 |
"http://ark.bnf.fr/ark:/12148/cb133192210", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
398 |
"http://ark.bnf.fr/ark:/12148/cb119377452", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
399 |
"http://ark.bnf.fr/ark:/12148/cb13320451h", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
400 |
"http://ark.bnf.fr/ark:/12148/cb13318422n", |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
401 |
"http://ark.bnf.fr/ark:/12148/cb11975823c" |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
402 |
]; |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
403 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
404 |
$doc->setSubjects($newSubjects); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
405 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
406 |
$this->assertTrue($doc->isDirty(), "The document must have changed"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
407 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
408 |
$subjects = $doc->getSubjects(); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
409 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
410 |
$this->assertCount(12, $subjects, "Must have 12 subjects"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
411 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
412 |
foreach ($doc->getSubjects() as $s) { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
413 |
$this->assertInstanceOf('EasyRdf\Resource', $s, "Mustbe a Resource"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
414 |
$this->assertTrue(strrpos($s->getUri(), "http://ark.bnf.fr/ark:/12148/cb") === 0, "Must start with http://ark.bnf.fr/ark:/12148/cb"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
415 |
$this->assertContains($s->getUri(), $newSubjects, "$s must be in new subjects list"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
416 |
if(($key = array_search($s->getUri(), $newSubjects)) !== false) { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
417 |
unset($newSubjects[$key]); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
418 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
419 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
420 |
$this->assertEmpty($newSubjects, "all subjects must have been removed"); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
421 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
422 |
|
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
423 |
//TODO: test null transcript + null media array |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
424 |
public function testJsonSerialize() { |
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
425 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
426 |
|
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
427 |
$json = $doc->jsonSerialize(); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
428 |
|
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
429 |
$this->assertTrue(is_array($json), 'Returned json must be an array'); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
430 |
$this->assertEquals( |
498
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
431 |
[ "id", "uri", "title", "languages", "modified", "issued", |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
432 |
"created", "publishers", "contributors", "subjects", "types", |
500
4f507ba2bb4c
add alternativeTitle. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
498
diff
changeset
|
433 |
"transcript", "mediaArray", "geoInfo", "descriptions", |
4f507ba2bb4c
add alternativeTitle. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
498
diff
changeset
|
434 |
"alternativeTitle" ], |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
435 |
array_keys($json) |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
436 |
); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
437 |
$this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
438 |
$this->assertTrue(is_array($json['transcript'])); |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
439 |
$this->assertTrue(is_array($json['mediaArray'])); |
497
f3474aeec884
add contry code in indexation, Serialize types, prepare #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
440 |
$this->assertTrue(is_array($json['subjects'])); |
f3474aeec884
add contry code in indexation, Serialize types, prepare #0025746
ymh <ymh.work@gmail.com>
parents:
445
diff
changeset
|
441 |
$this->assertTrue(is_array($json['types'])); |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
442 |
|
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
443 |
} |
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
143
diff
changeset
|
444 |
|
277
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
445 |
public function testAddGeoInfo() { |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
446 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
447 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_GEOINFO']); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
448 |
//$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
449 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
450 |
$res = $doc->addGeoInfo(); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
451 |
$res->commit(); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
452 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
453 |
$this->assertNotNull($res, "A new georesource object must have been created"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
454 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
455 |
$this->assertInstanceOf('CorpusParole\Models\GeoResource', $res, "the object created must be a geo resource"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
456 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
457 |
$allSpatials = $doc->getProvidedCHO()->allResources("<http://purl.org/dc/terms/spatial>"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
458 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
459 |
$this->assertCount(1, $allSpatials, "Must have only one spatial node"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
460 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
461 |
$spatial = $allSpatials[0]; |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
462 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
463 |
$this->assertTrue($spatial->isBNode(), "Spatial node must be a blank node"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
464 |
$this->assertEquals($spatial->typeAsResource(), "http://www.europeana.eu/schemas/edm/Place", "type must be a http://www.europeana.eu/schemas/edm/Place"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
465 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
466 |
$this->assertTrue($doc->isDirty(), "Document must be dirty"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
467 |
$this->assertEquals(1, $doc->deltaCount(), "Must have only one delta."); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
468 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
469 |
$this->assertNotNull($res->getCurrentDelta(), "CurrentDelta is not null"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
470 |
$this->assertTrue($res->getCurrentDelta()->getDeletedGraph()->isEmpty(), "deleted graph must be empty"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
471 |
$this->assertEmpty($res->getCurrentDelta()->getDeleteWhere(), "Delete where must be empty"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
472 |
$this->assertNotNull($res->getCurrentDelta()->getAddedGraph(), "Added graph is not null"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
473 |
$this->assertEquals(2, $res->getCurrentDelta()->getAddedGraph()->countTriples(), "Added graph must have 2 triples"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
474 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
475 |
} |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
476 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
477 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
478 |
public function testAddGeoInfoNotEmpty() { |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
479 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
480 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
481 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
482 |
$res = $doc->addGeoInfo(); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
483 |
$res->commit(); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
484 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
485 |
$this->assertNotNull($res, "A new georesource object must have been created"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
486 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
487 |
$this->assertInstanceOf('CorpusParole\Models\GeoResource', $res, "the object created must be a geo resource"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
488 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
489 |
$allSpatials = $doc->getProvidedCHO()->allResources("<http://purl.org/dc/terms/spatial>"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
490 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
491 |
$this->assertCount(1, $allSpatials, "Must have only one spatial node"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
492 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
493 |
$spatial = $allSpatials[0]; |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
494 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
495 |
$this->assertTrue($spatial->isBNode(), "Spatial node must be a blank node"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
496 |
$this->assertEquals($spatial->typeAsResource(), "http://www.europeana.eu/schemas/edm/Place", "type must be a http://www.europeana.eu/schemas/edm/Place"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
497 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
498 |
$this->assertTrue($doc->isDirty(), "Document must not be dirty"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
499 |
$this->assertEquals(1, $doc->deltaCount(), "Must have only one delta."); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
500 |
|
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
501 |
$this->assertNotNull($res->getCurrentDelta(), "CurrentDelta is not null"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
502 |
$this->assertTrue($res->getCurrentDelta()->getDeletedGraph()->isEmpty(), "deleted graph must be empty"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
503 |
$this->assertCount(1, $res->getCurrentDelta()->getDeleteWhere(), "Delete where must have one element"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
504 |
$this->assertNotNull($res->getCurrentDelta()->getAddedGraph(), "Added graph is not null"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
505 |
$this->assertEquals(9, $res->getCurrentDelta()->getAddedGraph()->countTriples(), "Added graph must have 7 triples"); |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
506 |
} |
bd4bc1db4f40
add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents:
169
diff
changeset
|
507 |
|
498
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
508 |
public function testDescriptions() { |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
509 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
510 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
511 |
$descriptions = $doc->getDescriptions(); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
512 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
513 |
$this->assertTrue(is_array($descriptions)); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
514 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
515 |
$this->assertCount(4, $descriptions); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
516 |
} |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
517 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
518 |
public function testNoDescription() { |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
519 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_DESCRIPTION']); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
520 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
521 |
$descriptions = $doc->getDescriptions(); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
522 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
523 |
$this->assertTrue(is_array($descriptions)); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
524 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
525 |
$this->assertCount(0, $descriptions); |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
526 |
} |
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
527 |
|
265992e5b379
Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents:
497
diff
changeset
|
528 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
529 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
530 |
} |