server/src/tests/Models/DocumentTest.php
author ymh <ymh.work@gmail.com>
Tue, 12 Apr 2016 13:42:04 +0200
changeset 151 95dfb40ff3d2
parent 143 023b6d467566
child 168 17f10b56c079
permissions -rw-r--r--
upgrade php dependencies
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
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
use CorpusParole\Models\Document;
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
     4
use CorpusParole\Libraries\CocoonUtils;
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
/**
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 *
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
class DocumentTest extends TestCase {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
    const TEST_DOC = <<<EOT
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    12
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    13
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    14
    @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    15
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    16
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    17
    @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    18
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    19
    <%1\$scrdo-CFPP2000_35_SOUND> a <http://www.openarchives.org/ore/terms/Aggregation> ;
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    20
        <http://www.europeana.eu/schemas/edm/aggregatedCHO> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    21
        <http://www.europeana.eu/schemas/edm/dataProvider> "Langage et langues : description, théorisation, transmission" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    22
        <http://www.europeana.eu/schemas/edm/hasView> <http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml> , <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3> , <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    23
        <http://www.europeana.eu/schemas/edm/isShownAt> <http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-CFPP2000_35_SOUND> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    24
        <http://www.europeana.eu/schemas/edm/isShownBy> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    25
        <http://www.europeana.eu/schemas/edm/provider> "Corpus de la Parole"@fr ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    26
        <http://www.europeana.eu/schemas/edm/rights> <http://creativecommons.org/licenses/by-nc-sa/4.0/> .
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    27
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    28
    <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    29
        <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    30
        <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    31
        <http://purl.org/dc/terms/extent> "PT48M26S" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    32
        <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    33
        <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    34
        <http://purl.org/dc/elements/1.1/contributor> <http://viaf.org/viaf/93752300> , "Tanguy, Noalig" , "Chevrier, Michel" , "Kiliç, Ozgur" , "Salvegas, Etienne" , "du-Breuil-de-Pont-en-Auge, Augustin" , "du-Breuil-de-Pont-en-Auge, Benoît" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    35
        <http://purl.org/dc/elements/1.1/description> "Enregistrement issu du Corpus de Français Parlé Parisien des années 2000 (CFPP2000)"@fr , "Quartier(s) concerné(s) : Paris 3e, et 20e (pour l'âge adulte); Anonymisation : Noalig TANGUY;"@fr ;
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    36
        <http://purl.org/dc/elements/1.1/identifier> "ark:/87895/1.17-375004" , "%2\$scrdo-CFPP2000_35_SOUNDid" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35" , "Cote producteur: [03-01] Ozgur_Kilic_H_32_alii_3e"@fr , "ark:/87895/1.17-372593" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35_SOUND" ;
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    37
        <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    38
        <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/142432638>;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    39
        <http://purl.org/dc/elements/1.1/subject> <http://ark.bnf.fr/ark:/12148/cb13318415c> , "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> , <http://lexvo.org/id/iso639-3/fra> , <http://ark.bnf.fr/ark:/12148/cb133188907> , <http://ark.bnf.fr/ark:/12148/cb11932762f> , "general_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb133183660> , "text_and_corpus_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "Français"@fr , <http://ark.bnf.fr/ark:/12148/cb122368540> , "phonology"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "semantics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "sociolinguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "syntax"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "typology"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb119418302> , <http://ark.bnf.fr/ark:/12148/cb135540729> , "discourse_analysis"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "historical_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , "language_documentation"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb133192210> , <http://ark.bnf.fr/ark:/12148/cb119377452> , <http://ark.bnf.fr/ark:/12148/cb13320451h> , <http://ark.bnf.fr/ark:/12148/cb13318422n> , <http://ark.bnf.fr/ark:/12148/cb11975823c> , "mathematical_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    40
        <http://purl.org/dc/elements/1.1/title> "Entretien de Ozgur Kiliç 2"@fr ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    41
        <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> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , <http://purl.org/dc/dcmitype/Text> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "report"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , "unintelligible_speech"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    42
        <http://purl.org/dc/terms/available> "2013-10-12"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    43
        <http://purl.org/dc/terms/spatial> [
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    44
            a <http://www.europeana.eu/schemas/edm/Place> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    45
            owl:sameAs <http://sws.geonames.org/6618626/> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    46
            <http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    47
        ];
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    48
        <http://www.europeana.eu/schemas/edm/isGatheredInto> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    49
        <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/93752300> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    50
        <http://www.language-archives.org/OLAC/1.1/interviewer> <http://viaf.org/viaf/93752300> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    51
        <http://www.language-archives.org/OLAC/1.1/transcriber> "Tanguy, Noalig" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    52
        <http://purl.org/dc/elements/1.1/coverage> "Quartier concerné : 3e"@fr ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    53
        <http://www.language-archives.org/OLAC/1.1/responder> "Chevrier, Michel" , "Kiliç, Ozgur" , "Salvegas, Etienne" , "du-Breuil-de-Pont-en-Auge, Augustin" , "du-Breuil-de-Pont-en-Auge, Benoît" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    54
        <http://purl.org/dc/elements/1.1/relation> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_31_SOUND> .
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    55
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    56
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    57
    <http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml> a <http://www.europeana.eu/schemas/edm/WebResource> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    58
        <http://purl.org/dc/elements/1.1/format> "application/xml"^^<http://purl.org/dc/terms/IMT> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    59
        <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    60
        <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    61
        <http://purl.org/dc/terms/issued> "2013-11-04T22:20:07+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    62
        <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    63
        <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_transcriber> .
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    64
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    65
    <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    66
        <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    67
        <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    68
        <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    69
        <http://purl.org/dc/terms/extent> "PT48M26S" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    70
        <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    71
        <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> .
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    72
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    73
    <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3> a <http://www.europeana.eu/schemas/edm/WebResource> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    74
        <http://purl.org/dc/elements/1.1/format> "audio/mpeg"^^<http://purl.org/dc/terms/IMT> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    75
        <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    76
        <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    77
        <http://purl.org/dc/terms/extent> "PT48M26S" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    78
        <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    79
        <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    80
        <http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> .
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    81
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    82
    <http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav> a <http://www.europeana.eu/schemas/edm/WebResource> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    83
        <http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    84
        <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    85
        <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    86
        <http://purl.org/dc/terms/extent> "PT48M26S" ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    87
        <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    88
        <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
    89
        <http://www.europeana.eu/schemas/edm/isDerivativeOf> <http://cocoon.huma-num.fr/data/archi/masters/372593.wav> .
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
EOT;
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
    public function setUp() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
        parent::setup();
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    96
        $this->graph = new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(DocumentTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme')));
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
    public function testConstructor() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        $this->assertNotNull($this->graph, 'Graph shoud not be null');
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   103
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   105
        $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
    public function testTitle() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
        $this->assertNotNull($this->graph, 'Graph shoud not be null');
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   111
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   113
        $this->assertEquals("Entretien de Ozgur Kiliç 2",$doc->getTitle(),'Must have correct title');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   114
        $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getTitle(), "Title must be a literal");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
        $this->assertEquals('fr', $doc->getTitle()->getLang(), "Language title must be fr");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   118
    public function testModified() {
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   119
        $this->assertNotNull($this->graph, 'Graph shoud not be null');
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   120
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   121
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   122
        $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   123
        $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   124
        $this->assertEquals("2013-10-12T14:35:57+02:00", $doc->getModified(), "modified must be 2013-10-12T14:35:57+02:00");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   125
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   126
    }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   127
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   128
    public function testSetModified() {
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   129
        $currentTime = gmdate(DateTime::ATOM);
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   130
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   131
        $doc->setModified($currentTime);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   132
        $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   133
        $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   134
        $this->assertEquals(preg_replace('/[\+\-]00(\:?)00$/', 'Z', $currentTime), $doc->getModified()->getValue(), "modified must be $currentTime");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   135
    }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   136
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   137
    public function testSetModifiedNull() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   138
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   139
        $doc->setModified();
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   140
        $this->assertInstanceOf(EasyRdf\Literal::class, $doc->getModified(), "Modified must be a literal");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   141
        $this->assertEquals("http://purl.org/dc/terms/W3CDTF", $doc->getModified()->getDatatypeURI(), "type must be http://purl.org/dc/terms/W3CDTF");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   142
        $foundDateTime = \DateTime::createFromFormat(\DateTime::ATOM, $doc->getModified()->getValue());
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   143
        $nowUTC = new \DateTime('now', new \DateTimeZone("UTC"));
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   144
        $this->assertTrue($nowUTC->getTimestamp() -  $foundDateTime->getTimestamp() < 2, "must have less than 2 seconds diff");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   145
    }
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   146
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
    public function testPublisher() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   149
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
        $this->assertCount(1, $doc->getPublishers(), 'Publisher is an array of size 1');
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   152
        $this->assertInstanceOf('EasyRdf\Resource', $doc->getPublishers()[0], 'publisher is a resource');
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   153
        $this->assertEquals("http://viaf.org/viaf/142432638", $doc->getPublishers()[0]->getUri(),"");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
    public function testMediaArray() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   157
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   159
        $this->assertCount(4, $doc->getMediaArray(), "Media array must be of size 4");
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   160
        //print_r($doc->getMediaArray());
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   161
        foreach($doc->getMediaArray() as $url => $media) {
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
            $this->assertArrayHasKey('format', $media, "media has 'format key'");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
            $this->assertArrayHasKey('url', $media, "media has url");
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   164
            $this->assertCount(5, $media, "media is a 4 element array");
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   165
            $this->assertArrayHasKey('extent', $media, "media has extent");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   166
            $this->assertArrayHasKey('extent_ms', $media, "media has extent_ms");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   167
            $this->assertArrayHasKey('master', $media, "media has master");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   168
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   169
            $this->assertEquals($media['url'], $url);
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   170
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   171
            $this->assertContains(
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   172
                $media['url'],
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   173
                [ "http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav",
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   174
                  "http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3",
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   175
                  "http://cocoon.huma-num.fr/exist/crdo/cfpp2000/fra/Ozgur_Kilic_H_32_alii_3e-2.xml",
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   176
                  "http://cocoon.huma-num.fr/data/archi/masters/372593.wav"
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   177
                ]
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   178
            );
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   179
            if($url === "http://cocoon.huma-num.fr/data/archi/masters/372593.wav") {
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   180
                $this->assertEquals('audio/x-wav', $media['format']);
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   181
                $this->assertTrue($media['master'] === true, "should be master");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   182
            }
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   183
            else {
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   184
                $this->assertTrue($media['master'] === false, "should not be master");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   185
            }
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   186
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   187
            if( $url === "http://cocoon.huma-num.fr/data/archi/masters/372593.wav" ||
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   188
                $url === "http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.mp3" ||
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   189
                $url === "http://cocoon.huma-num.fr/data/cfpp2000/Ozgur_Kilic_H_32_alii_3e-2.wav" ) {
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   190
                $this->assertEquals("PT48M26S", $media['extent'], "extent is PT48M26S");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   191
                $this->assertGreaterThan(0, $media['extent_ms'], "extent_ms must be > 0");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   192
                $this->assertStringStartsWith('audio/', $media['format']);
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   193
            }
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   194
            else {
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   195
                $this->assertNull($media['extent'], "no media extent");
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   196
                $this->assertNull($media['extent_ms'], "extend in ms is null");
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   197
                $this->assertStringStartsWith('application/', $media['format']);
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   198
            }
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   199
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
    public function testGetTypes() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   204
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   206
        $this->assertCount(8, $doc->getTypes(), "types array must be of size 5");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
        foreach($doc->getTypes() as $type) {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
            $this->assertThat(
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
                $type,
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
                $this->logicalXor(
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   212
                    $this->isInstanceOf(EasyRdf\Literal::class),
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   213
                    $this->isInstanceOf(EasyRdf\Resource::class)
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
                )
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
            );
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
    public function testGetOtherTypes() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   220
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   222
        $this->assertCount(5, $doc->getOtherTypes(), "types array must be of size 5");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
        foreach($doc->getTypes() as $type) {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
            $this->assertThat(
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
                $type,
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
                $this->logicalXor(
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   228
                    $this->isInstanceOf(EasyRdf\Literal::class),
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   229
                    $this->isInstanceOf(EasyRdf\Resource::class)
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
                )
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
            );
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
    public function testGetDiscourseTypes() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   236
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   238
        $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   240
        $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $doc->getDiscourseTypes(), "Result contains only literals");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
        $type = $doc->getDiscourseTypes()[0];
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   242
        $this->assertEquals("narrative", $type->getValue(), "discourse type is narrative");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
        $this->assertEquals("http://www.language-archives.org/OLAC/1.1/discourse-type", $type->getDatatypeUri(), "discourse type url");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
    public function testCloneDocument() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   247
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
        $doc2 = clone $doc;
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
        $this->assertNotSame($doc, $doc2, "documents must not be the same");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
        $this->assertNotSame($doc->getGraph(), $doc2->getGraph(), "documents must not be the same");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   254
        $this->assertTrue(EasyRdf\Isomorphic::isomorphic($doc->getGraph(), $doc2->getGraph()),"graph must be isomorphic");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
    public function testIsIsomorphic() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   258
        $doc1 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   259
        $doc2 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(DocumentTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))));
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
        $this->assertTrue($doc1->isIsomorphic($doc2),"document must be isomorphic");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   263
        $doc2->addLiteral('dc11:type', new EasyRdf\Literal("oratory", null, Config::get('OLAC_DISCOURSE_TYPE')['uri']));
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
        $this->assertFalse($doc1->isIsomorphic($doc2),"document must not be isomorphic");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
    public function testUpdateDiscourseTypes() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   270
        $newDiscourseTypes = ['oratory','dialogue','narrative', 'formulaic', 'ludic'];
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   272
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   273
        $this->assertCount(3, $doc->getDiscourseTypes(), "types array must be of size 3");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
        $doc->updateDiscourseTypes($newDiscourseTypes);
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   277
        $this->assertCount(5, $doc->getDiscourseTypes(), "types array must be of size 5");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
        $discourseTypes = $doc->getDiscourseTypes();
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
        foreach($newDiscourseTypes as $dt) {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
            $this->assertContains($dt, $discourseTypes, "all discourse types must be in result list");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   286
    public function testUpdateDiscourseTypesDelta() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   287
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   288
        $newDiscourseTypes = ['oratory','dialogue','narrative', 'formulaic', 'ludic'];
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   289
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   290
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   291
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   292
        $doc->updateDiscourseTypes($newDiscourseTypes);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   293
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   294
        $this->assertTrue($doc->isDirty());
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   295
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   296
        $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   297
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   298
        $delta = $doc->getDeltaList()[0];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   299
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   300
        $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $delta->getDeletedGraph()->getUri(), "uri of deleted graph must be ok");
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   301
        $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $delta->getAddedGraph()->getUri(), "uri of added graph must be ok");
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   302
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   303
        $this->assertEquals(3, $delta->getDeletedGraph()->countTriples(), "deleted graph must have only 3 triples");
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   304
        $this->assertEquals(5, $delta->getAddedGraph()->countTriples(), "deleted graph must have only 5 triples");
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   305
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   306
        $resQueryDiscourseType = $delta->getAddedGraph()->allLiterals($doc->getProvidedCHO(), 'dc11:type');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   307
        foreach($resQueryDiscourseType as $dt) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   308
            $this->assertInstanceOf(EasyRdf\Literal::class, $dt, "This must be a litteral");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   309
            $this->assertEquals('http://www.language-archives.org/OLAC/1.1/discourse-type', $dt->getDatatypeUri(), "The type of the Litteral must be correct");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   310
        }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   311
        foreach($newDiscourseTypes as $dt) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   312
            $this->assertContains($dt, $resQueryDiscourseType, "all discourse types must be in result list");
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   313
        }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   314
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   315
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   316
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   317
    public function testUpdateTitle() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   318
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   319
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   320
        $oldTitle = $doc->getTitle();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   321
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   322
        $doc->setTitle("new title", "en");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   323
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   324
        $this->assertEquals("new title", $doc->getTitleValue());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   325
        $this->assertEquals("new title", $doc->getTitle()->getValue());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   326
        $this->assertEquals("en", $doc->getTitle()->getLang());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   327
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   328
        $this->assertTrue($doc->isDirty());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   329
        $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   330
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   331
        $delta = $doc->getDeltaList()[0];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   332
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   333
        $addedTitles = $delta->getAddedGraph()->allLiterals($doc->getProvidedCHO(), '<http://purl.org/dc/elements/1.1/title>');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   334
        $this->assertCount(1, $addedTitles);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   335
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   336
        $removedTitles = $delta->getDeletedGraph()->allLiterals($doc->getProvidedCHO(), '<http://purl.org/dc/elements/1.1/title>');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   337
        $this->assertCount(1, $removedTitles);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   338
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   339
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   340
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   341
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
    public function testUpdateDiscourseTypesIsomorphic() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
        $newDiscourseTypes = ['oratory','dialogue','narrative'];
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   346
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
        $doc->updateDiscourseTypes($newDiscourseTypes);
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   349
        $doc2 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(DocumentTest::TEST_DOC, config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme'))));
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
        $this->assertFalse($doc->isIsomorphic($doc2),"document must not be isomorphic after adding discourse type");
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
    }
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   353
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   354
    public function testGetContributors() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   355
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   356
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   357
        $contributors = $doc->getContributors();
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   358
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   359
        $this->assertNotEmpty($contributors, "The contributors array should not be empty");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   360
        $this->assertCount(8, $contributors, "The contributors array should have 8 elements");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   361
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   362
        foreach ($contributors as $contribDef) {
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   363
            $this->assertArrayHasKey('name', $contribDef, "ContribDef must have name key");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   364
            $this->assertArrayHasKey('url', $contribDef, "ContribDef must have url key");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   365
            $this->assertArrayHasKey('role', $contribDef, "ContribDef must have role key");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   366
            $this->assertContains($contribDef['role'], CocoonUtils::OLAC_ROLES, "Role should be in OLAC_ROLES");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   367
        }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   368
    }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   369
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   370
    public function testSetContributors() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   371
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   372
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   373
        $contributors = $doc->getContributors();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   374
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   375
        $contribList = [[
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   376
            "name"=> "Guylaine Brun-Trigaud",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   377
            "url"=> "http://viaf.org/viaf/56666014",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   378
            "role"=> "http://www.language-archives.org/OLAC/1.1/data_inputter"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   379
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   380
            "name"=> "LDOR",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   381
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   382
            "role"=> "http://www.language-archives.org/OLAC/1.1/depositor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   383
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   384
            "name"=> "Thésaurus Occitan",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   385
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   386
            "role"=> "http://www.language-archives.org/OLAC/1.1/depositor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   387
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   388
            "name"=> "Équipe de Recherche en Syntaxe et Sémantique",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   389
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   390
            "role"=> "http://www.language-archives.org/OLAC/1.1/editor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   391
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   392
            "name"=> "Bases, corpus, langage",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   393
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   394
            "role"=> "http://www.language-archives.org/OLAC/1.1/editor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   395
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   396
            "name"=> "Patrick Sauzet",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   397
            "url"=> "http://viaf.org/viaf/51700729",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   398
            "role"=> "http://www.language-archives.org/OLAC/1.1/researcher"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   399
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   400
            "name"=> "Alazet, Pierre",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   401
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   402
            "role"=> "http://www.language-archives.org/OLAC/1.1/speaker"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   403
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   404
            "name"=> "Del Duca, Jeanne",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   405
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   406
            "role"=> "http://www.language-archives.org/OLAC/1.1/transcriber"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   407
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   408
            "name"=> "Jane Austen, 1775-1817",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   409
            "url"=> "http://viaf.org/viaf/102333412",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   410
            "role"=> "http://www.language-archives.org/OLAC/1.1/compiler"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   411
        ]];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   412
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   413
        $doc->setContributors($contribList);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   414
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   415
        $newContribs = $doc->getContributors();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   416
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   417
        $this->assertCount(9, $newContribs);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   418
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   419
        $this->assertTrue($doc->isDirty());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   420
        $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   421
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   422
        $delta = $doc->getDeltaList()[0];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   423
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   424
        $addedGraph = $delta->getAddedGraph();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   425
        $this->assertEquals(9, $addedGraph->countTriples());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   426
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   427
        $removedGraph = $delta->getDeletedGraph();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   428
        $this->assertEquals(count($contributors), $removedGraph->countTriples());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   429
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   430
        $foundJaneAusten = false;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   431
        foreach ($newContribs as $contribDef) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   432
            if(!is_null($contribDef['nameLiteral'])) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   433
                $lit = $contribDef['nameLiteral'];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   434
                $this->assertNull($lit->getDatatype(), "Data type must be null $lit");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   435
                $this->assertNotNull($lit->getLang(), "lang must not be null $lit");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   436
            }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   437
            if($contribDef['url'] == 'http://viaf.org/viaf/102333412') {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   438
                $this->assertNull($contribDef['name'], 'Name must be null');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   439
                $this->assertNull($contribDef['nameLiteral'], 'Name literal must be null');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   440
                $foundJaneAusten = true;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   441
            }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   442
        }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   443
        $this->assertTrue($foundJaneAusten, "Jane austenn not foud");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   444
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   445
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   446
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   447
    public function testGetSubjects() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   448
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   449
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   450
        $subjects = $doc->getSubjects();
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   451
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   452
        $this->assertCount(28, $subjects, "Must have 28 subjects");
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   453
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   454
        foreach ($doc->getSubjects() as $s) {
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   455
            $this->assertThat(
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   456
                $s,
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   457
                $this->logicalXor(
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   458
                    $this->isInstanceOf('EasyRdf\Literal'),
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   459
                    $this->isInstanceOf('EasyRdf\Resource')
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   460
                )
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   461
            );
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   462
        }
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   463
    }
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 122
diff changeset
   464
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   465
    public function testSetSubjects() {
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   466
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->graph);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   467
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   468
        $newSubjects = [
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   469
            "http://ark.bnf.fr/ark:/12148/cb13318415c",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   470
            "http://ark.bnf.fr/ark:/12148/cb133188907",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   471
            "http://ark.bnf.fr/ark:/12148/cb11932762f",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   472
            "http://ark.bnf.fr/ark:/12148/cb133183660",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   473
            "http://ark.bnf.fr/ark:/12148/cb122368540",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   474
            "http://ark.bnf.fr/ark:/12148/cb119418302",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   475
            "http://ark.bnf.fr/ark:/12148/cb135540729",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   476
            "http://ark.bnf.fr/ark:/12148/cb133192210",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   477
            "http://ark.bnf.fr/ark:/12148/cb119377452",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   478
            "http://ark.bnf.fr/ark:/12148/cb13320451h",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   479
            "http://ark.bnf.fr/ark:/12148/cb13318422n",
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   480
            "http://ark.bnf.fr/ark:/12148/cb11975823c"
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   481
        ];
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   482
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   483
        $doc->setSubjects($newSubjects);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   484
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   485
        $this->assertTrue($doc->isDirty(), "The document must have changed");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   486
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   487
        $subjects = $doc->getSubjects();
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   488
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   489
        $this->assertCount(12, $subjects, "Must have 12 subjects");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   490
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   491
        foreach ($doc->getSubjects() as $s) {
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   492
            $this->assertInstanceOf('EasyRdf\Resource', $s, "Mustbe a Resource");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   493
            $this->assertTrue(strrpos($s->getUri(), "http://ark.bnf.fr/ark:/12148/cb") === 0, "Must start with http://ark.bnf.fr/ark:/12148/cb");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   494
            $this->assertContains($s->getUri(), $newSubjects, "$s must be in new subjects list");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   495
            if(($key = array_search($s->getUri(), $newSubjects)) !== false) {
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   496
                unset($newSubjects[$key]);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   497
            }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   498
        }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   499
        $this->assertEmpty($newSubjects, "all subjects must have been removed");
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   500
    }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   501
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   502
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
}