server/src/tests/Models/DocumentTest.php
author ymh <ymh.work@gmail.com>
Wed, 15 Feb 2017 22:53:52 +0100
changeset 512 cf4653cf88f2
parent 502 74fba571487e
permissions -rw-r--r--
Added tag 0.0.16 for changeset fbf4e1afab01
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
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
     6
use EasyRdf\RdfNamespace;
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
     7
2
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
 *
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
class DocumentTest extends TestCase {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    13
    const TEST_INPUT_DOCS = [
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    14
        'TEST' => __DIR__.'/files/DocumentTest/test_doc.ttl',
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    15
        'TEST_NO_GEOINFO' => __DIR__.'/files/DocumentTest/test_no_geoinfo.ttl',
498
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
    16
        'TEST_NO_DESCRIPTION' => __DIR__.'/files/DocumentTest/test_doc_no_description.ttl',
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    17
    ];
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    18
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    19
    private $inputGraphes = [];
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    public function setUp() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    22
        parent::setup();
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    24
        foreach(self::TEST_INPUT_DOCS as $key => $inputDoc) {
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    25
            $this->inputGraphes[$key] =  new EasyRdf\Graph(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", sprintf(file_get_contents($inputDoc), config('corpusparole.corpus_doc_id_base_uri'), config('corpusparole.corpus_id_scheme')));
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    26
        }
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    27
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    public function testConstructor() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    32
        $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    34
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
    36
        $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
    37
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    39
    public function testCocoonId() {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    40
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    41
        $this->assertEquals('crdo-CFPP2000_35_SOUND',$doc->getCocoonId(),'Must have the correct cocoon id');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    42
    }
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    43
    public function testCocoonIdWithIdBefore() {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    44
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    45
        $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-CFPP2000_35_SOUNDid',$doc->getId(),'Must have the correct id');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    46
        $this->assertEquals('crdo-CFPP2000_35_SOUND',$doc->getCocoonId(),'Must have the correct cocoon id');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    47
    }
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
    48
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    public function testTitle() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    50
        $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    52
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
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
    54
        $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
    55
        $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
    56
        $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
    57
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    59
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    60
    public function testModified() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    61
        $this->assertNotNull($this->inputGraphes['TEST'], 'Graph shoud not be null');
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    62
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    63
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    64
        $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
    65
        $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
    66
        $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
    67
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    68
    }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    69
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
    70
    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
    71
        $currentTime = gmdate(DateTime::ATOM);
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    72
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
    73
        $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
    74
        $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
    75
        $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
    76
        $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
    77
    }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
    78
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
    79
    public function testSetModifiedNull() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    80
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
    81
        $doc->setModified();
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
    82
        $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
    83
        $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
    84
        $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
    85
        $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
    86
        $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
    87
    }
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    88
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
    public function testPublisher() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    91
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
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
        $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
    94
        $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
    95
        $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
    96
    }
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
    public function testMediaArray() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    99
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   101
        $this->assertCount(3, $doc->getMediaArray(), "Media array must be of size 3");
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
   102
        //print_r($doc->getMediaArray());
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   103
        foreach($doc->getMediaArray() as $media) {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   104
            $this->assertInstanceOf('CorpusParole\Models\MediaResource', $media, "media msute of type MediaResource");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   105
            // $this->assertArrayHasKey('format', $media, "media has 'format key'");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   106
            // $this->assertArrayHasKey('url', $media, "media has url");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   107
            // $this->assertCount(5, $media, "media is a 4 element array");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   108
            // $this->assertArrayHasKey('extent', $media, "media has extent");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   109
            // $this->assertArrayHasKey('extent_ms', $media, "media has extent_ms");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   110
            // $this->assertArrayHasKey('master', $media, "media has master");
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   111
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   112
            //$this->assertEquals($media['url'], $url);
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   113
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   114
            $this->assertContains(
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   115
                $media->getUrl(),
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   116
                [ "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
   117
                  "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
   118
                  "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
   119
                ]
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   120
            );
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   121
            if($media->getUrl() === "http://cocoon.huma-num.fr/data/archi/masters/372593.wav") {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   122
                $this->assertEquals('audio/x-wav', $media->getFormat());
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   123
                $this->assertTrue($media->isMaster() === true, "should be master");
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   124
            }
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   125
            else {
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   126
                $this->assertTrue($media->isMaster() === false, "should not be master");
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   127
            }
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   128
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   129
            $this->assertEquals("PT48M26S", $media->getExtent(), "extent is PT48M26S");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   130
            $this->assertGreaterThan(0, $media->getExtentMs(), "extent_ms must be > 0");
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   131
            $this->assertStringStartsWith('audio/', $media->getFormat());
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
    public function testGetTypes() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   136
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
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
   138
        $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
   139
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
        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
   141
            $this->assertThat(
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
                $type,
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
                $this->logicalXor(
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   144
                    $this->isInstanceOf(EasyRdf\Literal::class),
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   145
                    $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
   146
                )
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
            );
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
    }
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
    public function testGetOtherTypes() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   152
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   154
        $this->assertCount(6, $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
   155
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
        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
   157
            $this->assertThat(
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
                $type,
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
                $this->logicalXor(
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   160
                    $this->isInstanceOf(EasyRdf\Literal::class),
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   161
                    $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
   162
                )
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
            );
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
    public function testGetDiscourseTypes() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   168
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   170
        $this->assertCount(2, $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
   171
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   172
        $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $doc->getDiscourseTypes(), "Result contains only Resources");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
        $type = $doc->getDiscourseTypes()[0];
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   174
        $this->assertEquals("http://ark.bnf.fr/ark:/12148/cb11932135w", $type->getUri(), "discourse type is cb11932135w");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
    public function testCloneDocument() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   178
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
        $doc2 = clone $doc;
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
        $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
   183
        $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
   184
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   185
        $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
   186
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
    public function testIsIsomorphic() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   189
        $doc1 = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   190
        $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(file_get_contents(DocumentTest::TEST_INPUT_DOCS['TEST']) , 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
   191
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
        $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
   193
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   194
        $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
   195
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
        $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
   197
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
    public function testUpdateDiscourseTypes() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   201
        $newDiscourseTypes = ["http://ark.bnf.fr/ark:/12148/cb11932135w" , "http://ark.bnf.fr/ark:/12148/cb13319048g", "http://ark.bnf.fr/ark:/12148/cb11949715t" , "http://ark.bnf.fr/ark:/12148/cb119783362"];
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   203
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   204
        $this->assertCount(2, $doc->getDiscourseTypes(), "types array must be of size 2");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
        $doc->updateDiscourseTypes($newDiscourseTypes);
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   208
        $this->assertCount(4, $doc->getDiscourseTypes(), "types array must be of size 4");
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
        $discourseTypes = $doc->getDiscourseTypes();
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
        foreach($newDiscourseTypes as $dt) {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
            $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
   213
        }
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
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   217
    public function testUpdateDiscourseTypesDelta() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   218
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   219
        $newDiscourseTypes = ["http://ark.bnf.fr/ark:/12148/cb11932135w" , "http://ark.bnf.fr/ark:/12148/cb13319048g", "http://ark.bnf.fr/ark:/12148/cb11949715t" , "http://ark.bnf.fr/ark:/12148/cb119783362"];
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   220
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   221
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   222
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   223
        $doc->updateDiscourseTypes($newDiscourseTypes);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   224
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   225
        $this->assertTrue($doc->isDirty());
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   226
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   227
        $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
   228
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   229
        $delta = $doc->getDeltaList()[0];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   230
143
023b6d467566 Change id prefix + url + correct tests
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   231
        $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
   232
        $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
   233
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   234
        $this->assertEquals(2, $delta->getDeletedGraph()->countTriples(), "deleted graph must have only 2 triples");
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   235
        $this->assertEquals(4, $delta->getAddedGraph()->countTriples(), "deleted graph must have only 4 triples");
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   236
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   237
        $resQueryDiscourseType = $delta->getAddedGraph()->allResources($doc->getProvidedCHO(), 'dc11:type');
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   238
        foreach($resQueryDiscourseType as $dt) {
371
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   239
            $this->assertInstanceOf(EasyRdf\Resource::class, $dt, "This must be a Resource");
0365fd9977a4 Discourse types are now bnf ark resources
ymh <ymh.work@gmail.com>
parents: 326
diff changeset
   240
            $this->assertRegexp(config('corpusparole.bnf_ark_url_regexp'), $dt->getUri(), "The resource uri must be bnf ark");
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   241
        }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   242
        foreach($newDiscourseTypes as $dt) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   243
            $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
   244
        }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   245
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   246
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   247
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   248
    public function testUpdateTitle() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   249
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   250
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   251
        $oldTitle = $doc->getTitle();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   252
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   253
        $doc->setTitle("new title", "en");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   254
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   255
        $this->assertEquals("new title", $doc->getTitleValue());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   256
        $this->assertEquals("new title", $doc->getTitle()->getValue());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   257
        $this->assertEquals("en", $doc->getTitle()->getLang());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   258
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   259
        $this->assertTrue($doc->isDirty());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   260
        $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   261
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   262
        $delta = $doc->getDeltaList()[0];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   263
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   264
        $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
   265
        $this->assertCount(1, $addedTitles);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   266
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   267
        $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
   268
        $this->assertCount(1, $removedTitles);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   269
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   270
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   271
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   272
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
    public function testUpdateDiscourseTypesIsomorphic() {
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
        $newDiscourseTypes = ['oratory','dialogue','narrative'];
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   277
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
        $doc->updateDiscourseTypes($newDiscourseTypes);
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   280
        $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(file_get_contents(DocumentTest::TEST_INPUT_DOCS['TEST']), 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
   281
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
        $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
   283
    }
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
   284
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   285
    public function testGetContributors() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   286
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   287
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   288
        $contributors = $doc->getContributors();
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   289
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   290
        $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
   291
        $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
   292
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   293
        foreach ($contributors as $contribDef) {
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   294
            $this->assertArrayHasKey('name', $contribDef, "ContribDef must have name key");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   295
            $this->assertArrayHasKey('url', $contribDef, "ContribDef must have url key");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   296
            $this->assertArrayHasKey('role', $contribDef, "ContribDef must have role key");
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   297
            $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
   298
        }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   299
    }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   300
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   301
    public function testSetContributors() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   302
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   303
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   304
        $contributors = $doc->getContributors();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   305
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   306
        $contribList = [[
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   307
            "name"=> "Guylaine Brun-Trigaud",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   308
            "url"=> "http://viaf.org/viaf/56666014",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   309
            "role"=> "http://www.language-archives.org/OLAC/1.1/data_inputter"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   310
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   311
            "name"=> "LDOR",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   312
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   313
            "role"=> "http://www.language-archives.org/OLAC/1.1/depositor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   314
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   315
            "name"=> "ThƩsaurus Occitan",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   316
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   317
            "role"=> "http://www.language-archives.org/OLAC/1.1/depositor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   318
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   319
            "name"=> "Ɖquipe de Recherche en Syntaxe et SĆ©mantique",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   320
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   321
            "role"=> "http://www.language-archives.org/OLAC/1.1/editor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   322
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   323
            "name"=> "Bases, corpus, langage",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   324
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   325
            "role"=> "http://www.language-archives.org/OLAC/1.1/editor"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   326
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   327
            "name"=> "Patrick Sauzet",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   328
            "url"=> "http://viaf.org/viaf/51700729",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   329
            "role"=> "http://www.language-archives.org/OLAC/1.1/researcher"
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
            "name"=> "Alazet, Pierre",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   332
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   333
            "role"=> "http://www.language-archives.org/OLAC/1.1/speaker"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   334
        ], [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   335
            "name"=> "Del Duca, Jeanne",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   336
            "url"=> null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   337
            "role"=> "http://www.language-archives.org/OLAC/1.1/transcriber"
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
            "name"=> "Jane Austen, 1775-1817",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   340
            "url"=> "http://viaf.org/viaf/102333412",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   341
            "role"=> "http://www.language-archives.org/OLAC/1.1/compiler"
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   342
        ]];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   343
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   344
        $doc->setContributors($contribList);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   345
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   346
        $newContribs = $doc->getContributors();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   347
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   348
        $this->assertCount(9, $newContribs);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   349
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   350
        $this->assertTrue($doc->isDirty());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   351
        $this->assertEquals(1, $doc->deltaCount(), "There is one delta");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   352
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   353
        $delta = $doc->getDeltaList()[0];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   354
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   355
        $addedGraph = $delta->getAddedGraph();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   356
        $this->assertEquals(9, $addedGraph->countTriples());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   357
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   358
        $removedGraph = $delta->getDeletedGraph();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   359
        $this->assertEquals(count($contributors), $removedGraph->countTriples());
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   360
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   361
        $foundJaneAusten = false;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   362
        foreach ($newContribs as $contribDef) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   363
            if(!is_null($contribDef['nameLiteral'])) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   364
                $lit = $contribDef['nameLiteral'];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   365
                $this->assertNull($lit->getDatatype(), "Data type must be null $lit");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   366
                $this->assertNotNull($lit->getLang(), "lang must not be null $lit");
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   367
            }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   368
            if($contribDef['url'] == 'http://viaf.org/viaf/102333412') {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   369
                $this->assertNull($contribDef['name'], 'Name must be null');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   370
                $this->assertNull($contribDef['nameLiteral'], 'Name literal must be null');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   371
                $foundJaneAusten = true;
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
        }
497
f3474aeec884 add contry code in indexation, Serialize types, prepare #0025746
ymh <ymh.work@gmail.com>
parents: 445
diff changeset
   374
        $this->assertTrue($foundJaneAusten, "Jane Austeen not foud");
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   375
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   376
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   377
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
   378
    public function testGetSubjects() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   379
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
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
   380
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
   381
        $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
   382
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   383
        $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
   384
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
   385
        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
   386
            $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
   387
                $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
   388
                $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
   389
                    $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
   390
                    $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
   391
                )
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
   392
            );
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
   393
        }
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
   394
    }
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
   395
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   396
    public function testSetSubjects() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   397
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   398
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   399
        $newSubjects = [
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   400
            "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
   401
            "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
   402
            "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
   403
            "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
   404
            "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
   405
            "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
   406
            "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
   407
            "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
   408
            "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
   409
            "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
   410
            "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
   411
            "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
   412
        ];
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   413
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   414
        $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
   415
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   416
        $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
   417
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   418
        $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
   419
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   420
        $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
   421
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   422
        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
   423
            $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
   424
            $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
   425
            $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
   426
            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
   427
                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
   428
            }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   429
        }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   430
        $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
   431
    }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   432
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   433
    //TODO: test null transcript + null media array
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   434
    public function testJsonSerialize() {
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   435
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   436
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   437
        $json = $doc->jsonSerialize();
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   438
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   439
        $this->assertTrue(is_array($json), 'Returned json must be an array');
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   440
        $expectedKeys = [ "id", "cocoonId", "uri", "title", "languages", "modified", "issued",
498
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   441
              "created", "publishers", "contributors", "subjects", "types",
500
4f507ba2bb4c add alternativeTitle. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 498
diff changeset
   442
              "transcript", "mediaArray", "geoInfo", "descriptions",
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   443
              "alternativeTitle", "rights"];
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   444
        sort($expectedKeys);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   445
        $arrayKeys = array_keys($json);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   446
        sort($arrayKeys);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   447
        $this->assertEquals($expectedKeys, $arrayKeys);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   448
        $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   449
        $this->assertTrue(is_array($json['transcript']));
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   450
        $this->assertTrue(is_array($json['mediaArray']));
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   451
        $this->assertTrue(is_array($json['subjects']));
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   452
        $this->assertTrue(is_array($json['types']));
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   453
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   454
    }
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   455
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   456
    public function testJsonSerializeSetCountryCode() {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   457
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   458
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   459
        $doc->setCountryCode('3017382');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   460
        $json = $doc->jsonSerialize();
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   461
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   462
        $this->assertTrue(is_array($json), 'Returned json must be an array');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   463
        $expectedKeys = [ "id", "cocoonId", "uri", "title", "languages", "modified", "issued",
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   464
              "created", "publishers", "contributors", "subjects", "types",
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   465
              "transcript", "mediaArray", "geoInfo", "descriptions",
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   466
              "alternativeTitle", "rights", 'countryCode' ];
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   467
        sort($expectedKeys);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   468
        $arrayKeys = array_keys($json);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   469
        sort($arrayKeys);
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 501
diff changeset
   470
        $this->assertEquals($expectedKeys, $arrayKeys);
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   471
        $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']);
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   472
        $this->assertTrue(is_array($json['transcript']));
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   473
        $this->assertTrue(is_array($json['mediaArray']));
497
f3474aeec884 add contry code in indexation, Serialize types, prepare #0025746
ymh <ymh.work@gmail.com>
parents: 445
diff changeset
   474
        $this->assertTrue(is_array($json['subjects']));
f3474aeec884 add contry code in indexation, Serialize types, prepare #0025746
ymh <ymh.work@gmail.com>
parents: 445
diff changeset
   475
        $this->assertTrue(is_array($json['types']));
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   476
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   477
    }
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 143
diff changeset
   478
277
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   479
    public function testAddGeoInfo() {
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   480
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   481
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_GEOINFO']);
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   482
        //$doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   483
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   484
        $res = $doc->addGeoInfo();
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   485
        $res->commit();
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   486
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   487
        $this->assertNotNull($res, "A new georesource object must have been created");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   488
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   489
        $this->assertInstanceOf('CorpusParole\Models\GeoResource', $res, "the object created must be a geo resource");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   490
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   491
        $allSpatials = $doc->getProvidedCHO()->allResources("<http://purl.org/dc/terms/spatial>");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   492
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   493
        $this->assertCount(1, $allSpatials, "Must have only one spatial node");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   494
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   495
        $spatial = $allSpatials[0];
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   496
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   497
        $this->assertTrue($spatial->isBNode(), "Spatial node must be a blank node");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   498
        $this->assertEquals($spatial->typeAsResource(), "http://www.europeana.eu/schemas/edm/Place", "type must be a http://www.europeana.eu/schemas/edm/Place");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   499
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   500
        $this->assertTrue($doc->isDirty(), "Document must be dirty");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   501
        $this->assertEquals(1, $doc->deltaCount(), "Must have only one delta.");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   502
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   503
        $this->assertNotNull($res->getCurrentDelta(), "CurrentDelta is not null");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   504
        $this->assertTrue($res->getCurrentDelta()->getDeletedGraph()->isEmpty(), "deleted graph must be empty");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   505
        $this->assertEmpty($res->getCurrentDelta()->getDeleteWhere(), "Delete where must be empty");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   506
        $this->assertNotNull($res->getCurrentDelta()->getAddedGraph(), "Added graph is not null");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   507
        $this->assertEquals(2, $res->getCurrentDelta()->getAddedGraph()->countTriples(), "Added graph must have 2 triples");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   508
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   509
    }
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   510
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   511
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   512
    public function testAddGeoInfoNotEmpty() {
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   513
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   514
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   515
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   516
        $res = $doc->addGeoInfo();
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   517
        $res->commit();
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   518
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   519
        $this->assertNotNull($res, "A new georesource object must have been created");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   520
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   521
        $this->assertInstanceOf('CorpusParole\Models\GeoResource', $res, "the object created must be a geo resource");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   522
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   523
        $allSpatials = $doc->getProvidedCHO()->allResources("<http://purl.org/dc/terms/spatial>");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   524
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   525
        $this->assertCount(1, $allSpatials, "Must have only one spatial node");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   526
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   527
        $spatial = $allSpatials[0];
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   528
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   529
        $this->assertTrue($spatial->isBNode(), "Spatial node must be a blank node");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   530
        $this->assertEquals($spatial->typeAsResource(), "http://www.europeana.eu/schemas/edm/Place", "type must be a http://www.europeana.eu/schemas/edm/Place");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   531
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   532
        $this->assertTrue($doc->isDirty(), "Document must not be dirty");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   533
        $this->assertEquals(1, $doc->deltaCount(), "Must have only one delta.");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   534
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   535
        $this->assertNotNull($res->getCurrentDelta(), "CurrentDelta is not null");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   536
        $this->assertTrue($res->getCurrentDelta()->getDeletedGraph()->isEmpty(), "deleted graph must be empty");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   537
        $this->assertCount(1, $res->getCurrentDelta()->getDeleteWhere(), "Delete where must have one element");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   538
        $this->assertNotNull($res->getCurrentDelta()->getAddedGraph(), "Added graph is not null");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   539
        $this->assertEquals(9, $res->getCurrentDelta()->getAddedGraph()->countTriples(), "Added graph must have 7 triples");
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   540
    }
bd4bc1db4f40 add blank node save and geoinfo to back model
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   541
498
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   542
    public function testDescriptions() {
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   543
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST']);
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   544
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   545
        $descriptions = $doc->getDescriptions();
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   546
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   547
        $this->assertTrue(is_array($descriptions));
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   548
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   549
        $this->assertCount(4, $descriptions);
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   550
    }
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   551
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   552
    public function testNoDescription() {
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   553
        $doc = new Document(config('corpusparole.corpus_doc_id_base_uri')."crdo-CFPP2000_35_SOUND", $this->inputGraphes['TEST_NO_DESCRIPTION']);
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   554
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   555
        $descriptions = $doc->getDescriptions();
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   556
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   557
        $this->assertTrue(is_array($descriptions));
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   558
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   559
        $this->assertCount(0, $descriptions);
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   560
    }
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   561
265992e5b379 Add description to documents interface and indexation. Prepare #0025746
ymh <ymh.work@gmail.com>
parents: 497
diff changeset
   562
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   563
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
}