/**
  * @since 2.0
  *
  * @param mixed $expected
  * @param ExpResource $selectedElement
  * @param ExpData $exportData
  */
 public function assertThatExportDataContainsResource($expectedResources, ExpResource $selectedElement, ExpData $exportData)
 {
     $expElements = $exportData->getValues($selectedElement);
     $this->assertNotEmpty($expElements);
     $expectedResources = is_array($expectedResources) ? $expectedResources : array($expectedResources);
     $expectedToCount = count($expectedResources);
     $actualComparedToCount = 0;
     $assertThatExportDataContainsResource = false;
     foreach ($expElements as $expElement) {
         foreach ($expectedResources as $expectedResource) {
             if ($expectedResource->getHash() === $expElement->getHash()) {
                 $actualComparedToCount++;
                 $assertThatExportDataContainsResource = true;
             }
         }
     }
     $this->assertTrue($assertThatExportDataContainsResource, 'Asserts that a resource is set');
     $this->assertEquals($expectedToCount, $actualComparedToCount, 'Asserts that all listed resources are set');
 }
Example #2
0
 /**
  * Find a normalized representation of the given SMWExpData that can
  * be used in an update of the stored data. Normalization uses
  * redirects.
  * Moreover, the method records any auxiliary data that should be
  * written to the store when including this SMWExpElement into updates.
  * This auxiliary data is collected in a call-by-ref array.
  *
  * @since 1.6
  * @param $expData SMWExpData object containing the update data
  * @param $auxiliaryExpData array of SMWExpData
  * @param $expandSubject boolean controls if redirects/auxiliary data should also be sought for subject
  * @return SMWExpData
  */
 protected function expandUpdateExpData(SMWExpData $expData, array &$auxiliaryExpData, $expandSubject)
 {
     $subjectExpResource = $expData->getSubject();
     if ($expandSubject) {
         $expandedExpElement = $this->expandUpdateExpElement($subjectExpResource, $auxiliaryExpData);
         if ($expandedExpElement instanceof SMWExpData) {
             $newExpData = $expandedExpElement;
         } else {
             // instanceof SMWExpResource
             $newExpData = new SMWExpData($subjectExpResource);
         }
     } else {
         $newExpData = new SMWExpData($subjectExpResource);
     }
     foreach ($expData->getProperties() as $propertyResource) {
         $propertyTarget = $this->expandUpdateExpElement($propertyResource, $auxiliaryExpData);
         foreach ($expData->getValues($propertyResource) as $expElement) {
             $elementTarget = $this->expandUpdateExpElement($expElement, $auxiliaryExpData);
             $newExpData->addPropertyObjectValue($propertyTarget, $elementTarget);
         }
     }
     return $newExpData;
 }