server/src/tests/Controllers/DocumentListControllerTest.php
changeset 4 f55970e41793
parent 2 00e2916104fe
child 19 eadaf0b8f02e
equal deleted inserted replaced
3:2b3247d02769 4:f55970e41793
     1 <?php
     1 <?php
     2 
     2 
     3 use CorpusParole\Repositories\DocumentRepository;
     3 use CorpusParole\Repositories\DocumentRepository;
     4 use Mockery as m;
     4 use Mockery as m;
       
     5 use Illuminate\Pagination\LengthAwarePaginator;
       
     6 use CorpusParole\Models\Document;
     5 
     7 
     6 /**
     8 /**
     7  *
     9  *
     8  */
    10  */
     9 class DocumentListControllerTest extends TestCase {
    11 class DocumentListControllerTest extends TestCase {
       
    12 
       
    13     const GET_DOC = <<<EOD
       
    14     @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
       
    15     @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
       
    16     @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
       
    17     @prefix owl: <http://www.w3.org/2002/07/owl#> .
       
    18     @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
       
    19     @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
       
    20 
       
    21     <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-BOD092_SOUND> <http://purl.org/dc/elements/1.1/title> "Corpus LS émergente, L'oncle Geraldo, raconté par Ivaldo"@fr ;
       
    22         <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/202009521> , <http://viaf.org/viaf/74053259> ;
       
    23         <http://purl.org/dc/elements/1.1/rights> "Copyright (c) Cuxac, Christian" ;
       
    24         <http://purl.org/dc/elements/1.1/format> "video/mp4"^^<http://purl.org/dc/terms/IMT> ;
       
    25         <http://purl.org/dc/terms/isFormatOf> <http://cocoon.huma-num.fr/data/boutet/BOD092_low.mp4> , <http://cocoon.huma-num.fr/data/boutet/BOD092_low.ogg> ;
       
    26         <http://purl.org/dc/elements/1.1/subject> <http://lexvo.org/id/iso639-3/und> , "general_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> ;
       
    27         <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/und> ;
       
    28         <http://purl.org/dc/elements/1.1/type> "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> , <http://purl.org/dc/dcmitype/MovingImage> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> ;
       
    29         <http://www.language-archives.org/OLAC/1.1/author> "Fusellier-Souza, Ivani" ;
       
    30         <http://www.language-archives.org/OLAC/1.1/interviewer> "Fusellier-Souza, Ivani" ;
       
    31         <http://www.language-archives.org/OLAC/1.1/compiler> "Boutet, Dominique" , "Cuxac, Christian" ;
       
    32         <http://www.language-archives.org/OLAC/1.1/data_inputter> "Fiore, Sonia" , "Lacroix, Magdalena" , "Boutet, Dominique" ;
       
    33         <http://www.language-archives.org/OLAC/1.1/speaker> "Ivaldo, Lucia" ;
       
    34         <http://www.language-archives.org/OLAC/1.1/translator> "Fusellier-Souza, Ivani" ;
       
    35         <http://purl.org/dc/elements/1.1/description> """Cette séquence fait partie du corpus vidéo de Langue des
       
    36             Signes Emergentes utilisé lors de la thèse d'Ivani Fusellier-Souza : le locuteur Ivaldo
       
    37             raconte que son oncle Geraldo est riche mais n'est pas radin, et qu'il y a très
       
    38             longtemps lorsque les affaires marchaient pour son"""@fr ;
       
    39         <http://purl.org/dc/terms/alternative> "Séquence 13, L'oncle Geraldo, raconté par Ivaldo"@fr ;
       
    40         <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
       
    41         <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-nd/2.5/> ;
       
    42         <http://purl.org/dc/terms/spatial> "Brésil, Brasilia"@fr , "BR"^^<http://purl.org/dc/terms/ISO3166> ;
       
    43         <http://www.w3.org/2003/01/geo/wgs84_pos#long> "-47.9291"^^xsd:float ;
       
    44         <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "-15.7801"^^xsd:float ;
       
    45         <http://purl.org/dc/terms/created> "2001-03"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    46         <http://purl.org/dc/terms/tableOfContents> """00:00:00>00:00:45 Ivaldo raconte que son oncle
       
    47             Geraldo est riche. C'est un homme cultivé, qui a beaucoup d'argent. Il habite près de
       
    48             l'aéroport, où habite également l'amie de Lucia. La femme à Geraldo aussi est riche.
       
    49             00:00:45>00:00:46 Lucia dit qu'il est riche, tant mieux pour lui. 00:00:46>00:01:55
       
    50             Ivaldo raconte que son oncle était riche mais généreux. Il lui donne des billets d'avion
       
    51             pour voyager. Il lui donne également des vêtements. Ensuite, Ivaldo raconte qu'avant,
       
    52             son père était aisé et c'est l'oncle Geraldo qui ne l'était pas. Alors son père aidait
       
    53             l'oncle Geraldo car les affaires allaient bien. Mais par la suite, les affaires ont
       
    54             chutées et pour l'oncle Geraldo elles montaient."""@fr ;
       
    55         <http://purl.org/dc/terms/extent> "PT00H01M54S" ;
       
    56         <http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> ;
       
    57         <http://purl.org/dc/terms/issued> "2013-06-04T22:39:21+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    58         <http://crdo.risc.cnrs.fr/schemas/master> <http://cocoon.huma-num.fr/data/archi/masters/350801.mp4> ;
       
    59         <http://purl.org/dc/terms/available> "2013-06-04"^^<http://purl.org/dc/terms/W3CDTF> .
       
    60 
       
    61     <http://lexvo.org/id/iso639-3/und> rdfs:label "Langue des signes émergente"@fr .
       
    62 
       
    63     <http://viaf.org/viaf/202009521> rdfs:label "Boutet, Dominique" ;
       
    64         <http://xmlns.com/foaf/0.1/status> "depositor"^^<http://www.language-archives.org/OLAC/1.1/role> .
       
    65 
       
    66     <http://viaf.org/viaf/74053259> rdfs:label "Cuxac, Christian" ;
       
    67         <http://xmlns.com/foaf/0.1/status> "depositor"^^<http://www.language-archives.org/OLAC/1.1/role> .
       
    68 
       
    69 EOD;
       
    70 #""" comment for syntax highliting
    10 
    71 
    11     private $documentRepository;
    72     private $documentRepository;
    12 
    73 
    13     public function setUp() {
    74     public function setUp() {
    14 
    75 
    24         m::close();
    85         m::close();
    25         parent::tearDown();
    86         parent::tearDown();
    26     }
    87     }
    27 
    88 
    28     public function testIndex() {
    89     public function testIndex() {
    29         $this->documentRepository->shouldReceive('all')->once()->andReturn(array());
    90         $this->documentRepository
       
    91             ->shouldReceive('paginateAll')
       
    92             ->once()
       
    93             ->andReturn(
       
    94                 new LengthAwarePaginator([], 0, 10, 1, [
       
    95                     'path' => '',
       
    96                     'pageName' => 'page',
       
    97                 ]));
    30 
    98 
    31         $response = $this->call('GET', '/bo/docs');
    99         $response = $this->call('GET', '/bo/docs');
    32 
   100 
    33         $this->assertResponseOk($response);
   101         $this->assertResponseOk($response);
    34         $this->assertViewHas('docs');
   102         $this->assertViewHas('docs');
    35     }
   103     }
       
   104 
       
   105     public function testShow() {
       
   106         $res_doc = new EasyRdf\Graph('http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-BOD092_SOUND',DocumentListControllerTest::GET_DOC);
       
   107         $this->documentRepository
       
   108             ->shouldReceive('get')
       
   109             ->once()
       
   110             ->andReturn(new Document('http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-BOD092_SOUND', $res_doc));
       
   111 
       
   112         $response = $this->visit('/bo/docs/crdo-BOD092_SOUND');
       
   113 
       
   114     }
    36 }
   115 }