author | ymh <ymh.work@gmail.com> |
Thu, 02 Jun 2016 18:24:19 +0200 | |
changeset 168 | 17f10b56c079 |
parent 143 | 023b6d467566 |
child 277 | bd4bc1db4f40 |
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; |
|
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
|
9 |
use CorpusParole\Models\DocumentResult; |
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
|
10 |
|
4 | 11 |
|
12 |
use SebastianBergmann\Diff\Differ; |
|
13 |
||
14 |
use GuzzleHttp\Client; |
|
15 |
||
16 |
class DocumentRepositoryIntegrationTest extends TestCase { |
|
17 |
||
18 |
const REPO_CREATION_TTL = <<<EOT |
|
19 |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. |
|
20 |
@prefix rep: <http://www.openrdf.org/config/repository#>. |
|
21 |
@prefix sr: <http://www.openrdf.org/config/repository/sail#>. |
|
22 |
@prefix sail: <http://www.openrdf.org/config/sail#>. |
|
23 |
@prefix ms: <http://www.openrdf.org/config/sail/memory#>. |
|
24 |
||
25 |
[] a rep:Repository ; |
|
26 |
rep:repositoryID "%1\$s" ; |
|
27 |
rdfs:label "%1\$s test repository" ; |
|
28 |
rep:repositoryImpl [ |
|
29 |
rep:repositoryType "openrdf:SailRepository" ; |
|
30 |
sr:sailImpl [ |
|
31 |
sail:sailType "openrdf:MemoryStore" ; |
|
32 |
ms:persist false ; |
|
33 |
ms:syncDelay 0 |
|
34 |
] |
|
35 |
]. |
|
36 |
EOT; |
|
37 |
||
38 |
const TEST_DOC = <<<EOT |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
39 |
@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
|
40 |
@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
|
41 |
@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
|
42 |
@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
|
43 |
@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
|
44 |
@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
|
45 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
46 |
_:genid-2267740936ad4d04a567e6787732f0dd-genid1 a <http://www.europeana.eu/schemas/edm/Place> ; |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
47 |
owl:sameAs <http://sws.geonames.org/3038033/> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
48 |
<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 . |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
49 |
|
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
50 |
<%1\$scrdo-ALA_738> a <http://www.openarchives.org/ore/terms/Aggregation> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
51 |
<http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
52 |
<http://www.europeana.eu/schemas/edm/dataProvider> "Atlas linguistiques, cultures et parlers régionaux de France" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
53 |
<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> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
54 |
<http://www.europeana.eu/schemas/edm/isShownAt> <http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-ALA_738> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
55 |
<http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
56 |
<http://www.europeana.eu/schemas/edm/provider> "Corpus de la Parole"@fr ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
57 |
<http://www.europeana.eu/schemas/edm/rights> <http://creativecommons.org/licenses/by-nc-nd/4.0/> . |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
58 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
59 |
<http://cocoon.huma-num.fr/data/ala/ALA_738.mp3> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
60 |
<http://purl.org/dc/elements/1.1/format> "audio/mpeg"^^<http://purl.org/dc/terms/IMT> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
61 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
62 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
63 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
64 |
<http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> . |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
65 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
66 |
<http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
67 |
<http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
68 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
69 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
70 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> . |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
71 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
109
diff
changeset
|
72 |
<http://cocoon.huma-num.fr/data/ala/ALA_738_22km.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ; |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
73 |
<http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
74 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
75 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
76 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
77 |
<http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> . |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
78 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
79 |
<http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ; |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
80 |
<http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
81 |
<http://purl.org/dc/terms/extent> "PT01H11M29S" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
82 |
<http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
83 |
<http://purl.org/dc/elements/1.1/contributor> <http://viaf.org/viaf/61542329> , <http://viaf.org/viaf/9122216> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
84 |
<http://purl.org/dc/elements/1.1/description> "Extrait des enquêtes dialectologiques en vue de constituer un atlas linguistique de l'Alsace."@fr ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
85 |
<http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/gsw> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
86 |
<http://purl.org/dc/elements/1.1/publisher> "Atlas linguistiques, cultures et parlers régionaux de France" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
87 |
<http://purl.org/dc/elements/1.1/rights> "Copyright (c) Département de dialectologie alsacienne et mosellane de l'Université de Strasbourg" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
88 |
<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> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
89 |
<http://purl.org/dc/elements/1.1/title> "Atlas Linguistique et ethnographique de l'Alsace - Enquetes sur la conscience linguistique - ALA_738"@fr ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
90 |
<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> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
91 |
<http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
92 |
<http://purl.org/dc/terms/available> "2004-07-03"^^<http://purl.org/dc/terms/W3CDTF> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
93 |
<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> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
94 |
<http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-nd/2.5/> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
95 |
<http://purl.org/dc/terms/spatial> _:genid-2267740936ad4d04a567e6787732f0dd-genid1 ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
96 |
<http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/9122216> ; |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
97 |
<http://www.language-archives.org/OLAC/1.1/interviewer> <http://viaf.org/viaf/61542329> , <http://viaf.org/viaf/9122216> . |
4 | 98 |
EOT; |
99 |
||
100 |
function __construct(string $name = null) { |
|
101 |
parent::__construct($name); |
|
102 |
} |
|
103 |
||
104 |
public function setUp() { |
|
105 |
parent::setUp(); |
|
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
106 |
$this->graph = new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", sprintf(DocumentRepositoryIntegrationTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'))); |
4 | 107 |
|
108 |
$this->httpClient = new Client(['base_uri' => config('corpusparole.sesame_base_url')]); |
|
109 |
$this->sesameRepository = config('corpusparole.sesame_repository'); |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
110 |
$this->corpusDocIdBaseUri = config('corpusparole.corpus_doc_id_base_uri'); |
4 | 111 |
|
112 |
$this->documentRepository = $this->app->make('CorpusParole\Repositories\DocumentRepository'); |
|
113 |
$uniqueid = uniqid('corpusparole', true); |
|
114 |
$repoCreateStmt = sprintf(DocumentRepositoryIntegrationTest::REPO_CREATION_TTL, $this->sesameRepository); |
|
115 |
$this->httpClient->delete("repositories/$this->sesameRepository", ['http_errors' => false]); |
|
116 |
$this->httpClient->post('repositories/SYSTEM/statements', [ |
|
117 |
'headers' => ['Content-type' => 'application/x-turtle;charset=UTF-8'], |
|
118 |
'query' => ['context' => "_:$uniqueid"], |
|
119 |
'body' => $repoCreateStmt, |
|
120 |
]); |
|
121 |
$this->httpClient->put("repositories/$this->sesameRepository/statements", [ |
|
122 |
'headers' => ['Content-type' => 'text/turtle;charset=UTF-8'], |
|
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
123 |
'body' => sprintf(DocumentRepositoryIntegrationTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri')), |
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
124 |
'query' => ['context' => "<".config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738>"], |
4 | 125 |
]); |
126 |
} |
|
127 |
||
128 |
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
|
129 |
//$this->httpClient->delete("repositories/$this->sesameRepository"); |
4 | 130 |
parent::tearDown(); |
131 |
} |
|
132 |
||
133 |
public function testAll() { |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
134 |
$expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738'; |
4 | 135 |
$docList = $this->documentRepository->all(); |
136 |
$this->assertCount(1, $docList, "Should have one element"); |
|
137 |
||
138 |
$resDoc = $docList[0]; |
|
139 |
||
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
|
140 |
$this->assertInstanceOf(DocumentResult::class, $resDoc, "Res doc must be a Document"); |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
141 |
$this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $resDoc->getId(), "id must be crdo..."); |
4 | 142 |
$this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...'); |
26 | 143 |
$this->assertNotNull($resDoc->getGraph(), 'Graph must not be null'); |
4 | 144 |
|
145 |
} |
|
146 |
||
147 |
public function testGet() { |
|
148 |
||
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
149 |
$expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738'; |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
150 |
$returnedGraph = new EasyRdf\Graph($expectedId, sprintf(DocumentRepositoryIntegrationTest::TEST_DOC,config('corpusparole.corpus_doc_id_base_uri'))); |
4 | 151 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
152 |
$res = $this->documentRepository->get('crdo-ALA_738'); |
4 | 153 |
|
154 |
$this->assertInstanceOf(Document::class, $res, "Result must be of type Document"); |
|
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
155 |
$this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); |
4 | 156 |
$this->assertNotNull($res->getGraph(), "Graph shoul not be null"); |
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
157 |
$this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738",$res->getGraph()->getUri(), "uri of graph must be ".config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738"); |
4 | 158 |
$this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); |
159 |
} |
|
160 |
||
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
|
161 |
public function testGetShort() { |
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
|
162 |
|
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
|
163 |
$expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738'; |
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
|
164 |
$returnedGraph = new EasyRdf\Graph($expectedId, sprintf(DocumentRepositoryIntegrationTest::TEST_DOC,config('corpusparole.corpus_doc_id_base_uri'))); |
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
|
165 |
|
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
|
166 |
$res = $this->documentRepository->get('crdo-ALA_738', true); |
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
|
167 |
|
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
|
168 |
$this->assertInstanceOf(DocumentResult::class, $res, "Result must be of type DocumentResult"); |
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
|
169 |
$this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); |
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
|
170 |
$this->assertNotNull($res->getGraph(), "Graph shoul not be null"); |
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
|
171 |
$this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738",$res->getGraph()->getUri(), "uri of graph must be ".config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738"); |
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
|
172 |
$this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); |
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
|
173 |
} |
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
|
174 |
|
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
|
175 |
|
4 | 176 |
public function testSave() { |
177 |
||
143
023b6d467566
Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents:
122
diff
changeset
|
178 |
$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738", $this->graph); |
4 | 179 |
$doc->updateDiscourseTypes(['oratory','drama','narrative']); |
180 |
||
181 |
$res = $this->documentRepository->save($doc); |
|
182 |
||
183 |
$this->assertTrue($res, 'Has started a transaction'); |
|
184 |
||
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
4
diff
changeset
|
185 |
$res = $this->documentRepository->get('crdo-ALA_738'); |
4 | 186 |
|
187 |
$discoursesTypes = $res->getDiscourseTypes(); |
|
188 |
||
189 |
$this->assertCount(3, $discoursesTypes, "types array must be of size 1"); |
|
190 |
||
191 |
$this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $discoursesTypes, "Result contains only literals"); |
|
192 |
||
193 |
$newDiscoursesTypes = []; |
|
194 |
foreach($discoursesTypes as $dt) { |
|
195 |
array_push($newDiscoursesTypes, $dt->getValue()); |
|
196 |
$this->assertContains($dt->getValue(),['oratory','drama','narrative'],'Value in [oratory,drama,narrative]'); |
|
197 |
$this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $dt->getDatatypeUri(), "discourse type url"); |
|
198 |
} |
|
199 |
sort($newDiscoursesTypes); |
|
200 |
$this->assertEquals(['drama', 'narrative', 'oratory'], $newDiscoursesTypes, "array type must the same"); |
|
201 |
} |
|
202 |
||
203 |
public function testCount() { |
|
204 |
$res = $this->documentRepository->getCount(); |
|
205 |
||
206 |
$this->assertNotNull($res, "Res should not be null"); |
|
207 |
$this->assertSame(1, $res, "should heve only one document"); |
|
208 |
} |
|
209 |
||
210 |
||
211 |
} |