server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php
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--
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
use Illuminate\Support\Facades\Facade;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
use Illuminate\Support\Facades\Config;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
use CorpusParole\Repositories\DocumentRepository;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
use CorpusParole\Repositories\RdfDocumentRepository;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
use SebastianBergmann\Diff\Differ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
use GuzzleHttp\Client;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
class DocumentRepositoryIntegrationTest extends TestCase {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    const REPO_CREATION_TTL = <<<EOT
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    @prefix rep: <http://www.openrdf.org/config/repository#>.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    @prefix sr: <http://www.openrdf.org/config/repository/sail#>.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    @prefix sail: <http://www.openrdf.org/config/sail#>.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
    @prefix ms: <http://www.openrdf.org/config/sail/memory#>.
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    [] a rep:Repository ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        rep:repositoryID "%1\$s" ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
        rdfs:label "%1\$s test repository" ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
        rep:repositoryImpl [
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
            rep:repositoryType "openrdf:SailRepository" ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
            sr:sailImpl [
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
                sail:sailType "openrdf:MemoryStore" ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
                ms:persist false ;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
                ms:syncDelay 0
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
            ]
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
        ].
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
EOT;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
EOT;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
    function __construct(string $name = null) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        parent::__construct($name);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
    public function setUp() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
        $this->httpClient = new Client(['base_uri' => config('corpusparole.sesame_base_url')]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
        $this->documentRepository = $this->app->make('CorpusParole\Repositories\DocumentRepository');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
        $uniqueid = uniqid('corpusparole', true);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
        $repoCreateStmt = sprintf(DocumentRepositoryIntegrationTest::REPO_CREATION_TTL, $this->sesameRepository);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
        $this->httpClient->delete("repositories/$this->sesameRepository", ['http_errors' => false]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
        $this->httpClient->post('repositories/SYSTEM/statements', [
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
            'headers' => ['Content-type' => 'application/x-turtle;charset=UTF-8'],
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
            'query' => ['context' => "_:$uniqueid"],
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
            'body' => $repoCreateStmt,
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
        ]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
        $this->httpClient->put("repositories/$this->sesameRepository/statements", [
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
        ]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
        parent::tearDown();
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
        $docList = $this->documentRepository->all();
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
        $this->assertCount(1, $docList, "Should have one element");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
        $resDoc = $docList[0];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
        $this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...');
26
72f51a9386ff upgrade libs and correct tests
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   143
        $this->assertNotNull($resDoc->getGraph(), 'Graph must not be null');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
    public function testGet() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
        $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph));
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
    public function testSave() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
        $doc->updateDiscourseTypes(['oratory','drama','narrative']);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
        $res = $this->documentRepository->save($doc);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
        $this->assertTrue($res, 'Has started a transaction');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
        $discoursesTypes = $res->getDiscourseTypes();
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
        $this->assertCount(3, $discoursesTypes, "types array must be of size 1");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
        $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $discoursesTypes, "Result contains only literals");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
        $newDiscoursesTypes = [];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
        foreach($discoursesTypes as $dt) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
            array_push($newDiscoursesTypes, $dt->getValue());
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
            $this->assertContains($dt->getValue(),['oratory','drama','narrative'],'Value in [oratory,drama,narrative]');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
            $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $dt->getDatatypeUri(), "discourse type url");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
        }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
        sort($newDiscoursesTypes);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
        $this->assertEquals(['drama', 'narrative', 'oratory'], $newDiscoursesTypes, "array type must the same");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
    public function testCount() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
        $res = $this->documentRepository->getCount();
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
        $this->assertNotNull($res, "Res should not be null");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
        $this->assertSame(1, $res, "should heve only one document");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
}