author | ymh <ymh.work@gmail.com> |
Wed, 20 Jan 2016 16:21:40 +0100 | |
changeset 111 | af85c436048f |
parent 109 | d22ed5792f8e |
child 112 | 7a542145832c |
permissions | -rw-r--r-- |
4 | 1 |
<?php |
2 |
||
3 |
use Illuminate\Support\Facades\Facade; |
|
4 |
use Illuminate\Support\Facades\Config; |
|
5 |
||
6 |
use CorpusParole\Repositories\DocumentRepository; |
|
7 |
use CorpusParole\Repositories\RdfDocumentRepository; |
|
8 |
use CorpusParole\Models\Document; |
|
9 |
||
10 |
use SebastianBergmann\Diff\Differ; |
|
11 |
||
12 |
use GuzzleHttp\Client; |
|
13 |
||
14 |
class DocumentRepositoryIntegrationTest extends TestCase { |
|
15 |
||
16 |
const REPO_CREATION_TTL = <<<EOT |
|
17 |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. |
|
18 |
@prefix rep: <http://www.openrdf.org/config/repository#>. |
|
19 |
@prefix sr: <http://www.openrdf.org/config/repository/sail#>. |
|
20 |
@prefix sail: <http://www.openrdf.org/config/sail#>. |
|
21 |
@prefix ms: <http://www.openrdf.org/config/sail/memory#>. |
|
22 |
||
23 |
[] a rep:Repository ; |
|
24 |
rep:repositoryID "%1\$s" ; |
|
25 |
rdfs:label "%1\$s test repository" ; |
|
26 |
rep:repositoryImpl [ |
|
27 |
rep:repositoryType "openrdf:SailRepository" ; |
|
28 |
sr:sailImpl [ |
|
29 |
sail:sailType "openrdf:MemoryStore" ; |
|
30 |
ms:persist false ; |
|
31 |
ms:syncDelay 0 |
|
32 |
] |
|
33 |
]. |
|
34 |
EOT; |
|
35 |
||
36 |
const TEST_DOC = <<<EOT |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
37 |
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
38 |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
39 |
@prefix sesame: <http://www.openrdf.org/schema/sesame#> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
40 |
@prefix owl: <http://www.w3.org/2002/07/owl#> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
41 |
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
42 |
@prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
43 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
44 |
_:genid-2267740936ad4d04a567e6787732f0dd-genid1 a <http://www.europeana.eu/schemas/edm/Place> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
45 |
owl:sameAs <http://sws.geonames.org/3038033/> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
46 |
<http://www.w3.org/2004/02/skos/core#note> "northlimit=47.431892250000033; southlimit=49.053971250000046;westlimit=6.846186050000028; eastlimit=8.232571550000074;"^^<http://purl.org/dc/terms/Box> , "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Alsace"@fr . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
47 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
48 |
<###h#ttp://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ALA_738> a <http://www.openarchives.org/ore/terms/Aggregation> ; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
49 |
<http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
50 |
<http://www.europeana.eu/schemas/edm/dataProvider> "Atlas linguistiques, cultures et parlers régionaux de France" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
51 |
<http://www.europeana.eu/schemas/edm/hasView> <http://cocoon.huma-num.fr/data/ala/ALA_738.mp3> , <http://cocoon.huma-num.fr/data/ala/ALA_738_22km.wav> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
52 |
<http://www.europeana.eu/schemas/edm/isShownAt> <http://cocoon.huma-num.fr/exist/crdo/meta/crdo-ALA_738> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
53 |
<http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
54 |
<http://www.europeana.eu/schemas/edm/provider> "Corpus de la Parole"@fr ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
55 |
<http://www.europeana.eu/schemas/edm/rights> <http://creativecommons.org/licenses/by-nc-nd/4.0/> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
56 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
57 |
<http://cocoon.huma-num.fr/data/ala/ALA_738.mp3> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
58 |
<http://purl.org/dc/elements/1.1/format> "audio/mpeg"^^<http://purl.org/dc/terms/IMT> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
59 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
60 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
61 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
62 |
<http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
63 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
64 |
<http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
65 |
<http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
66 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
67 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
68 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
69 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
70 |
<http://cocoon.huma-num.fr/data/ala/ALA_738_22km.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
71 |
<http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
72 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
73 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
74 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
75 |
<http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> . |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
76 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
77 |
<http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
78 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
79 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
80 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
81 |
<http://purl.org/dc/elements/1.1/contributor> <http://viaf.org/viaf/61542329> , <http://viaf.org/viaf/9122216> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
82 |
<http://purl.org/dc/elements/1.1/description> "Extrait des enquêtes dialectologiques en vue de constituer un atlas linguistique de l'Alsace."@fr ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
83 |
<http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/gsw> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
84 |
<http://purl.org/dc/elements/1.1/publisher> "Atlas linguistiques, cultures et parlers régionaux de France" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
85 |
<http://purl.org/dc/elements/1.1/rights> "Copyright (c) Département de dialectologie alsacienne et mosellane de l'Université de Strasbourg" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
86 |
<http://purl.org/dc/elements/1.1/subject> <http://lexvo.org/id/iso639-3/gsw> , <http://ark.bnf.fr/ark:/12148/cb11931472p> , <http://ark.bnf.fr/ark:/12148/cb11931564b> , <http://ark.bnf.fr/ark:/12148/cb11932194d> , <http://ark.bnf.fr/ark:/12148/cb11933029x> , <http://ark.bnf.fr/ark:/12148/cb11933281k> , <http://ark.bnf.fr/ark:/12148/cb11934740m> , <http://ark.bnf.fr/ark:/12148/cb11935375d> , <http://ark.bnf.fr/ark:/12148/cb11935986q> , <http://ark.bnf.fr/ark:/12148/cb11936549n> , <http://ark.bnf.fr/ark:/12148/cb11937931x> , <http://ark.bnf.fr/ark:/12148/cb119392962> , <http://ark.bnf.fr/ark:/12148/cb119458243> , <http://ark.bnf.fr/ark:/12148/cb11946662b> , <http://ark.bnf.fr/ark:/12148/cb11947332t> , <http://ark.bnf.fr/ark:/12148/cb119481497> , <http://ark.bnf.fr/ark:/12148/cb119591726> , <http://ark.bnf.fr/ark:/12148/cb119756721> , <http://ark.bnf.fr/ark:/12148/cb119757609> , <http://ark.bnf.fr/ark:/12148/cb11975806s> , <http://ark.bnf.fr/ark:/12148/cb119759527> , <http://ark.bnf.fr/ark:/12148/cb12032030g> , <http://ark.bnf.fr/ark:/12148/cb12042429k> , <http://ark.bnf.fr/ark:/12148/cb12099148r> , <http://ark.bnf.fr/ark:/12148/cb12148936v> , <http://ark.bnf.fr/ark:/12148/cb12289036m> , <http://ark.bnf.fr/ark:/12148/cb13318335q> , <http://ark.bnf.fr/ark:/12148/cb133183540> , <http://ark.bnf.fr/ark:/12148/cb13318415c> , <http://ark.bnf.fr/ark:/12148/cb13318491g> , "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> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
87 |
<http://purl.org/dc/elements/1.1/title> "Atlas Linguistique et ethnographique de l'Alsace - Enquetes sur la conscience linguistique - ALA_738"@fr ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
88 |
<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> , "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
89 |
<http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
90 |
<http://purl.org/dc/terms/available> "2004-07-03"^^<http://purl.org/dc/terms/W3CDTF> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
91 |
<http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ALA_CL> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
92 |
<http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-nd/2.5/> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
93 |
<http://purl.org/dc/terms/spatial> _:genid-2267740936ad4d04a567e6787732f0dd-genid1 ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
94 |
<http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/9122216> ; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
95 |
<http://www.language-archives.org/OLAC/1.1/interviewer> <http://viaf.org/viaf/61542329> , <http://viaf.org/viaf/9122216> . |
4 | 96 |
EOT; |
97 |
||
98 |
function __construct(string $name = null) { |
|
99 |
parent::__construct($name); |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
100 |
$this->graph = new EasyRdf\Graph("http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ALA_738", DocumentRepositoryIntegrationTest::TEST_DOC); |
4 | 101 |
} |
102 |
||
103 |
public function setUp() { |
|
104 |
parent::setUp(); |
|
105 |
||
106 |
$this->httpClient = new Client(['base_uri' => config('corpusparole.sesame_base_url')]); |
|
107 |
$this->sesameRepository = config('corpusparole.sesame_repository'); |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
108 |
$this->corpusDocIdBaseUri = config('corpusparole.corpus_doc_id_base_uri'); |
4 | 109 |
|
110 |
$this->documentRepository = $this->app->make('CorpusParole\Repositories\DocumentRepository'); |
|
111 |
$uniqueid = uniqid('corpusparole', true); |
|
112 |
$repoCreateStmt = sprintf(DocumentRepositoryIntegrationTest::REPO_CREATION_TTL, $this->sesameRepository); |
|
113 |
$this->httpClient->delete("repositories/$this->sesameRepository", ['http_errors' => false]); |
|
114 |
$this->httpClient->post('repositories/SYSTEM/statements', [ |
|
115 |
'headers' => ['Content-type' => 'application/x-turtle;charset=UTF-8'], |
|
116 |
'query' => ['context' => "_:$uniqueid"], |
|
117 |
'body' => $repoCreateStmt, |
|
118 |
]); |
|
119 |
$this->httpClient->put("repositories/$this->sesameRepository/statements", [ |
|
120 |
'headers' => ['Content-type' => 'text/turtle;charset=UTF-8'], |
|
121 |
'body' => DocumentRepositoryIntegrationTest::TEST_DOC, |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
122 |
'query' => ['context' => '<http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ALA_738>'], |
4 | 123 |
]); |
124 |
} |
|
125 |
||
126 |
public function tearDown() { |
|
109
d22ed5792f8e
Correct transaction management. cf. bug https://openrdf.atlassian.net/browse/SES-2295 and tomcat default management of PUT request with form data (application/x-www-form-urlencoded encoded)
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
127 |
//$this->httpClient->delete("repositories/$this->sesameRepository"); |
4 | 128 |
parent::tearDown(); |
129 |
} |
|
130 |
||
131 |
public function testAll() { |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
132 |
$expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738'; |
4 | 133 |
$docList = $this->documentRepository->all(); |
134 |
$this->assertCount(1, $docList, "Should have one element"); |
|
135 |
||
136 |
$resDoc = $docList[0]; |
|
137 |
||
138 |
$this->assertInstanceOf(Document::class, $resDoc, "Res doc must be a Document"); |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
139 |
$this->assertEquals('crdo-ALA_738', $resDoc->getId(), "id must be crdo..."); |
4 | 140 |
$this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...'); |
26 | 141 |
$this->assertNotNull($resDoc->getGraph(), 'Graph must not be null'); |
4 | 142 |
|
143 |
} |
|
144 |
||
145 |
public function testGet() { |
|
146 |
||
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
147 |
$expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738'; |
4 | 148 |
$returnedGraph = new EasyRdf\Graph($expectedId, DocumentRepositoryIntegrationTest::TEST_DOC); |
149 |
||
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
150 |
$res = $this->documentRepository->get('crdo-ALA_738'); |
4 | 151 |
|
152 |
$this->assertInstanceOf(Document::class, $res, "Result must be of type Document"); |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
153 |
$this->assertEquals('crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); |
4 | 154 |
$this->assertNotNull($res->getGraph(), "Graph shoul not be null"); |
28 | 155 |
$this->assertEquals("http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ALA_738",$res->getGraph()->getUri(), "uri of graph must be http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ALA_738"); |
4 | 156 |
$this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); |
157 |
} |
|
158 |
||
159 |
public function testSave() { |
|
160 |
||
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
161 |
$doc = new Document("http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ALA_738", $this->graph); |
4 | 162 |
$doc->updateDiscourseTypes(['oratory','drama','narrative']); |
163 |
||
164 |
$res = $this->documentRepository->save($doc); |
|
165 |
||
166 |
$this->assertTrue($res, 'Has started a transaction'); |
|
167 |
||
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
168 |
$res = $this->documentRepository->get('crdo-ALA_738'); |
4 | 169 |
|
170 |
$discoursesTypes = $res->getDiscourseTypes(); |
|
171 |
||
172 |
$this->assertCount(3, $discoursesTypes, "types array must be of size 1"); |
|
173 |
||
174 |
$this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $discoursesTypes, "Result contains only literals"); |
|
175 |
||
176 |
$newDiscoursesTypes = []; |
|
177 |
foreach($discoursesTypes as $dt) { |
|
178 |
array_push($newDiscoursesTypes, $dt->getValue()); |
|
179 |
$this->assertContains($dt->getValue(),['oratory','drama','narrative'],'Value in [oratory,drama,narrative]'); |
|
180 |
$this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $dt->getDatatypeUri(), "discourse type url"); |
|
181 |
} |
|
182 |
sort($newDiscoursesTypes); |
|
183 |
$this->assertEquals(['drama', 'narrative', 'oratory'], $newDiscoursesTypes, "array type must the same"); |
|
184 |
} |
|
185 |
||
186 |
public function testCount() { |
|
187 |
$res = $this->documentRepository->getCount(); |
|
188 |
||
189 |
$this->assertNotNull($res, "Res should not be null"); |
|
190 |
$this->assertSame(1, $res, "should heve only one document"); |
|
191 |
} |
|
192 |
||
193 |
||
194 |
} |