server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php
changeset 116 e60c55988ed4
parent 115 34ffc04cef62
child 122 b37fde30dd4a
equal deleted inserted replaced
115:34ffc04cef62 116:e60c55988ed4
   266          $this->assertEquals(CocoonSoundRdfMapperTest::TEST_INPUT_ID, $identifier->getValue(), "Value must be equals to ".CocoonSoundRdfMapperTest::TEST_INPUT_ID);
   266          $this->assertEquals(CocoonSoundRdfMapperTest::TEST_INPUT_ID, $identifier->getValue(), "Value must be equals to ".CocoonSoundRdfMapperTest::TEST_INPUT_ID);
   267 
   267 
   268      }
   268      }
   269 
   269 
   270 
   270 
       
   271     public function testRightsWebResourceIdentity() {
       
   272         $properties = [
       
   273             "http://purl.org/dc/elements/1.1/rights",
       
   274             'http://purl.org/dc/terms/license',
       
   275         ];
       
   276 
       
   277         $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type');
       
   278         $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   279 
       
   280         foreach ($webResourceList as $webResource) {
       
   281             foreach ($properties as $prop) {
       
   282                 $outputValuesStr = [];
       
   283                 foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) {
       
   284                     array_push($outputValuesStr, strval($outputValue));
       
   285                 }
       
   286                 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop");
       
   287                 foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) {
       
   288                     $this->assertContains(strval($value), $outputValuesStr, "$prop not found in output graph");
       
   289                 }
       
   290             }
       
   291         }
       
   292     }
       
   293 
       
   294     public function testRightsWebResourceTrim() {
       
   295         $properties = [
       
   296             'http://purl.org/dc/terms/accessRights',
       
   297         ];
       
   298 
       
   299         $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type');
       
   300         $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   301 
       
   302         foreach ($webResourceList as $webResource) {
       
   303             foreach ($properties as $prop) {
       
   304                 $outputValuesStr = [];
       
   305                 foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) {
       
   306                     array_push($outputValuesStr, strval($outputValue));
       
   307                 }
       
   308                 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop");
       
   309                 foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) {
       
   310                     $this->assertContains(trim(strval($value)), $outputValuesStr, "$prop not found in output graph");
       
   311                 }
       
   312             }
       
   313         }
       
   314     }
       
   315 
   271     /**
   316     /**
   272      * Test one to one mapping
   317      * Test one to one mapping
   273      *
   318      *
   274      * @return void
   319      * @return void
   275      */
   320      */