server/src/tests/Repositories/DocumentRepositoryTest.php
author ymh <ymh.work@gmail.com>
Fri, 12 Feb 2016 15:30:32 +0100
changeset 122 b37fde30dd4a
parent 113 faff38055a07
child 129 4fca650b9b8a
permissions -rw-r--r--
correct problem of identifier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     3
use Illuminate\Support\Facades\Facade;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     5
use CorpusParole\Repositories\RdfDocumentRepository;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     6
use CorpusParole\Libraries\Sparql\SparqlClient;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     7
use CorpusParole\Models\Document;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     8
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     9
use Mockery as m;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    10
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
class DocumentRepositoryTest extends TestCase {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    13
    const TEST_DOC = <<<EOT
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    14
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    15
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    16
    @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    17
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    18
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    19
    @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    20
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    21
    _:genid-2267740936ad4d04a567e6787732f0dd-genid1 a <http://www.europeana.eu/schemas/edm/Place> ;
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    22
        owl:sameAs <http://sws.geonames.org/3038033/> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    23
        <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
    24
112
7a542145832c replace corpus doc base url
ymh <ymh.work@gmail.com>
parents: 111
diff changeset
    25
    <http://corpusdelaparole.huma-num.fr/corpus/res/crdo-ALA_738> a <http://www.openarchives.org/ore/terms/Aggregation> ;
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    26
        <http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    27
        <http://www.europeana.eu/schemas/edm/dataProvider> "Atlas linguistiques, cultures et parlers régionaux de France" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    28
        <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> ;
113
faff38055a07 change shownAt url to point to humanum
ymh <ymh.work@gmail.com>
parents: 112
diff changeset
    29
        <http://www.europeana.eu/schemas/edm/isShownAt> <http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-ALA_738> ;
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    30
        <http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    31
        <http://www.europeana.eu/schemas/edm/provider> "Corpus de la Parole"@fr ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    32
        <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
    33
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    34
    <http://cocoon.huma-num.fr/data/ala/ALA_738.mp3> a <http://www.europeana.eu/schemas/edm/WebResource> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    35
        <http://purl.org/dc/elements/1.1/format> "audio/mpeg"^^<http://purl.org/dc/terms/IMT> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    36
        <http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    37
        <http://purl.org/dc/terms/extent> "PT01H11M29S" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    38
        <http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    39
        <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
    40
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    41
    <http://cocoon.huma-num.fr/data/ala/masters/ALA_738.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    42
        <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    43
        <http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    44
        <http://purl.org/dc/terms/extent> "PT01H11M29S" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    45
        <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
    46
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    47
    <http://cocoon.huma-num.fr/data/ala/ALA_738_22km.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    48
        <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    49
        <http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    50
        <http://purl.org/dc/terms/extent> "PT01H11M29S" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    51
        <http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    52
        <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
    53
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    54
    <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ;
111
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    55
        <http://purl.org/dc/terms/created> "1996"^^<http://purl.org/dc/terms/Period> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    56
        <http://purl.org/dc/terms/extent> "PT01H11M29S" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    57
        <http://purl.org/dc/terms/issued> "2014-11-10T14:27:08+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    58
        <http://purl.org/dc/elements/1.1/contributor> <http://viaf.org/viaf/61542329> , <http://viaf.org/viaf/9122216> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    59
        <http://purl.org/dc/elements/1.1/description> "Extrait des enquêtes dialectologiques en vue de constituer un atlas linguistique de l'Alsace."@fr ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    60
        <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/gsw> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    61
        <http://purl.org/dc/elements/1.1/publisher> "Atlas linguistiques, cultures et parlers régionaux de France" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    62
        <http://purl.org/dc/elements/1.1/rights> "Copyright (c) Département de dialectologie alsacienne et mosellane de l'Université de Strasbourg" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    63
        <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> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    64
        <http://purl.org/dc/elements/1.1/title> "Atlas Linguistique et ethnographique de l'Alsace - Enquetes sur la conscience linguistique - ALA_738"@fr ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    65
        <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> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    66
        <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    67
        <http://purl.org/dc/terms/available> "2004-07-03"^^<http://purl.org/dc/terms/W3CDTF> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    68
        <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> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    69
        <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-nd/2.5/> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    70
        <http://purl.org/dc/terms/spatial> _:genid-2267740936ad4d04a567e6787732f0dd-genid1 ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    71
        <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/9122216> ;
af85c436048f change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents: 28
diff changeset
    72
        <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: 2
diff changeset
    73
EOT;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    74
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    75
    function __construct(string $name = null) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    76
        parent::__construct($name);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    77
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    78
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    79
    public function setUp() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    80
        parent::setUp();
112
7a542145832c replace corpus doc base url
ymh <ymh.work@gmail.com>
parents: 111
diff changeset
    81
        $this->graph = new EasyRdf\Graph("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-ALA_738", DocumentRepositoryTest::TEST_DOC);
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    82
        $this->corpusDocIdBaseUri = config('corpusparole.corpus_doc_id_base_uri');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    83
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    84
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    85
    public function tearDown() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    86
        parent::tearDown();
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    87
        m::close();
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    88
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    89
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    90
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    91
    public function testAll() {
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    92
        $expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738';
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    93
        $returnedArray = [
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    94
            m::mock('resObj', function($mock) use (&$expectedId) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    95
                $mock->uri = new EasyRdf\Resource($expectedId);
26
72f51a9386ff upgrade libs and correct tests
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    96
                $mock->doc = new EasyRdf\Resource("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ALA_738");
72f51a9386ff upgrade libs and correct tests
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    97
                $mock->title = new EasyRdf\Literal("Atlas Linguistique et ethnographique de l'Alsace - Enquetes sur la conscience linguistique - ALA_738", null, "fr");
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    98
            }),
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    99
        ];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   100
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   101
        $sparqlClientMock = m::mock('CorpusParole\Libraries\Sparql\SparqlClient');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   102
        $sparqlClientMock->shouldReceive('query')->andReturn($returnedArray);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   103
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   104
        $documentRepository = $this->app->make('CorpusParole\Repositories\RdfDocumentRepository', [$sparqlClientMock]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   105
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   106
        $res = $documentRepository->all();
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   107
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   108
        $this->assertCount(1, $res, "Should have 1 doc in res");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   109
        $resDoc = $res[0];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   110
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   111
        $this->assertInstanceOf(Document::class, $resDoc, "Res doc must be a Document");
122
b37fde30dd4a correct problem of identifier
ymh <ymh.work@gmail.com>
parents: 113
diff changeset
   112
        $this->assertEquals('corpusparole:crdo-ALA_738', $resDoc->getId(), "id must be crdo...");
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   113
        $this->assertEquals($expectedId, $resDoc->getUri(), 'url must be ...');
26
72f51a9386ff upgrade libs and correct tests
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   114
        $this->assertNotNull($resDoc->getGraph(), 'Graph must be not null');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   115
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   116
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   117
    public function testGet() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   118
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   119
        $expectedId = $this->corpusDocIdBaseUri.'crdo-ALA_738';
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   120
        $returnedGraph = new EasyRdf\Graph($expectedId, DocumentRepositoryTest::TEST_DOC);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   121
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   122
        $sparqlClientMock = m::mock('CorpusParole\Libraries\Sparql\SparqlClient');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   123
        $sparqlClientMock->shouldReceive('query')->with(containsString($expectedId))
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   124
                ->andReturn($returnedGraph);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   125
        $documentRepository = $this->app->make('CorpusParole\Repositories\RdfDocumentRepository', [$sparqlClientMock]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   126
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   127
        $res = $documentRepository->get('crdo-ALA_738');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   128
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   129
        $this->assertInstanceOf(Document::class, $res, "Result must be of type Document");
122
b37fde30dd4a correct problem of identifier
ymh <ymh.work@gmail.com>
parents: 113
diff changeset
   130
        $this->assertEquals('corpusparole: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: 2
diff changeset
   131
        $this->assertNotNull($res->getGraph(), "Graph shoul not be null");
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   132
        $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(), new EasyRdf\Graph($expectedId, DocumentRepositoryTest::TEST_DOC)));
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   133
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   134
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   135
    public function testSave() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   136
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   137
        $sparqlClientMock = m::mock('CorpusParole\Libraries\Sparql\SparqlClient', function($mock) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   138
            $mock->shouldReceive('startTransaction')->andReturn(true)
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   139
                ->shouldReceive('delete')->shouldReceive('add')
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   140
                ->shouldReceive('commit')->andReturn(true);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   141
        });
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   142
        $documentRepository = $this->app->make('CorpusParole\Repositories\RdfDocumentRepository', [$sparqlClientMock]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   143
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   144
112
7a542145832c replace corpus doc base url
ymh <ymh.work@gmail.com>
parents: 111
diff changeset
   145
        $doc = new Document("http://corpusdelaparole.huma-num.fr/corpus/res/crdo-ALA_738", $this->graph);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   146
        $doc->updateDiscourseTypes(['oratory','drama','narrative']);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   147
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   148
        $res = $documentRepository->save($doc);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   149
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   150
        $this->assertTrue($res, 'Has started a transaction');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   151
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   152
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   153
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   154
    public function testCount() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   155
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   156
        $returnedCount = [
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   157
            m::mock('resObj', function($mock) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   158
                $mock->count = new EasyRdf\Literal(1);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   159
            }),
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   160
        ];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   161
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   162
        $sparqlClientMock = m::mock('CorpusParole\Libraries\Sparql\SparqlClient');
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   163
        $sparqlClientMock->shouldReceive('query')->with(containsString("COUNT"))
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   164
                ->andReturn($returnedCount);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   165
        $documentRepository = $this->app->make('CorpusParole\Repositories\RdfDocumentRepository', [$sparqlClientMock]);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   166
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
}