server/src/tests/libraries/Mappers/CocoonTextRdfMapperTest.php
changeset 19 eadaf0b8f02e
parent 18 f2a40bbc27f6
child 111 af85c436048f
equal deleted inserted replaced
18:f2a40bbc27f6 19:eadaf0b8f02e
   125         $this->assertCount(1, $resources, "Must found only one resources of type edm:ProvidedCHO");
   125         $this->assertCount(1, $resources, "Must found only one resources of type edm:ProvidedCHO");
   126         $this->assertEquals(CocoonTextRdfMapperTest::TEST_CHO_URI,$resources[0]->getUri());
   126         $this->assertEquals(CocoonTextRdfMapperTest::TEST_CHO_URI,$resources[0]->getUri());
   127     }
   127     }
   128 
   128 
   129     /**
   129     /**
   130      * Test taht the returned graph does not have a http://purl.org/dc/dcmitype/Sound type
   130      * Test that the returned graph does not have a http://purl.org/dc/dcmitype/Sound type
   131      *
   131      *
   132      * @return void
   132      * @return void
   133      */
   133      */
   134     public function testType() {
   134     public function testType() {
   135         //"primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , <http://purl.org/dc/dcmitype/Text> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
   135         //"primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , <http://purl.org/dc/dcmitype/Text> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
   136         $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type');
   136         $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type');
   137 
   137 
   138         $this->assertNotNull($providedCHO);
   138         $this->assertNotNull($providedCHO);
   139 
   139 
   140         $this->assertEmpty($providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/type'), 'resource'), 'Should not find dc element:type value as resource');
   140         $this->assertcount(3, $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/type')), 'but should find 2 literals');
   141         $this->assertcount(2, $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/type')), 'but should find 2 literals');
       
   142 
       
   143         $expResMap = [
       
   144             'primary_text' => 'http://www.language-archives.org/OLAC/1.1/linguistic-type',
       
   145             'narrative' => 'http://www.language-archives.org/OLAC/1.1/discourse-type'
       
   146         ];
       
   147 
   141 
   148         $dcTypeList = $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/type'));
   142         $dcTypeList = $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/type'));
   149         foreach ($dcTypeList as $dcType) {
   143         foreach ($dcTypeList as $dcType) {
   150             $this->assertInstanceOf('EasyRdf\Literal', $dcType, "dc type must be a literal");
   144             $this->assertThat(
   151             $this->assertArrayHasKey($dcType->getValue(),$expResMap, 'Value must be in expected result Map');
   145                 $dcType,
   152             $this->assertEquals($expResMap[$dcType->getValue()], $dcType->getDatatypeUri());
   146                 $this->logicalXor(
       
   147                     $this->isInstanceOf(EasyRdf\Literal::class),
       
   148                     $this->isInstanceOf(EasyRdf\Resource::class)
       
   149                 )
       
   150             );
   153         }
   151         }
   154     }
   152     }
   155 
   153 
   156      /**
   154      /**
   157       * Test that the web resources
   155       * Test that the web resources