コード例 #1
0
 /**
  * @param ResponseSection $responseSection
  * @return bool
  */
 protected function matchesSection(ResponseSection $responseSection)
 {
     $records = $responseSection->getRecords();
     if (empty($records) || !is_array($records)) {
         $this->sectionFailures[$responseSection->getIdentifier()] = 'No records found.';
         return FALSE;
     }
     $nonMatchingValues = $this->getNonMatchingValues($records);
     if (!empty($nonMatchingValues)) {
         $this->sectionFailures[$responseSection->getIdentifier()] = 'Could not assert all values for "' . $this->table . '.' . $this->field . '": ' . implode(', ', $nonMatchingValues);
         return FALSE;
     }
     return TRUE;
 }
コード例 #2
0
 /**
  * @param ResponseSection $responseSection
  * @return bool
  */
 protected function matchesSection(ResponseSection $responseSection)
 {
     $records = $responseSection->getRecords();
     if (empty($records) || !is_array($records)) {
         $this->sectionFailures[$responseSection->getIdentifier()] = 'No records found.';
         return false;
     }
     $nonMatchingValues = $this->getNonMatchingValues($records);
     $matchingValues = array_diff($this->values, $nonMatchingValues);
     if (!empty($matchingValues)) {
         $this->sectionFailures[$responseSection->getIdentifier()] = 'Could not assert not having values for "' . $this->table . '.' . $this->field . '": ' . implode(', ', $matchingValues);
         return false;
     }
     return true;
 }
コード例 #3
0
 /**
  * @param ResponseSection $responseSection
  * @return bool
  */
 protected function matchesSection(ResponseSection $responseSection)
 {
     $nonMatchingVariants = array();
     $remainingRecordVariants = array();
     foreach ($responseSection->findStructures($this->recordIdentifier, $this->recordField) as $path => $structure) {
         if (empty($structure) || !is_array($structure)) {
             $this->sectionFailures[$responseSection->getIdentifier()] = 'No records found in "' . $path . '"';
             return false;
         }
         $remainingRecords = array();
         $nonMatchingValues = $this->getNonMatchingValues($structure);
         if ($this->strict) {
             $remainingRecords = $this->getRemainingRecords($structure);
         }
         if (empty($nonMatchingValues) && (!$this->strict || empty($remainingRecords))) {
             return true;
         }
         if (!empty($nonMatchingValues)) {
             $nonMatchingVariants[$path] = $nonMatchingValues;
         }
         if ($this->strict && !empty($remainingRecords)) {
             $remainingRecordVariants[$path] = $remainingRecords;
         }
     }
     $failureMessage = '';
     if (!empty($nonMatchingVariants)) {
         $failureMessage .= 'Could not assert all values for "' . $this->table . '.' . $this->field . '"' . LF;
         foreach ($nonMatchingVariants as $path => $nonMatchingValues) {
             $failureMessage .= '  * Not found in "' . $path . '": ' . implode(', ', $nonMatchingValues) . LF;
         }
     }
     if (!empty($remainingRecordVariants)) {
         $failureMessage .= 'Found remaining records for "' . $this->table . '.' . $this->field . '"' . LF;
         foreach ($remainingRecordVariants as $path => $remainingRecords) {
             $failureMessage .= '  * Found in "' . $path . '": ' . implode(', ', array_keys($remainingRecords)) . LF;
         }
     }
     $this->sectionFailures[$responseSection->getIdentifier()] = $failureMessage;
     return false;
 }
コード例 #4
0
 /**
  * @param ResponseSection $responseSection
  * @return bool
  */
 protected function matchesSection(ResponseSection $responseSection)
 {
     $matchingVariants = array();
     foreach ($responseSection->findStructures($this->recordIdentifier, $this->recordField) as $path => $structure) {
         if (empty($structure) || !is_array($structure)) {
             $this->sectionFailures[$responseSection->getIdentifier()] = 'No records found in "' . $path . '"';
             return FALSE;
         }
         $nonMatchingValues = $this->getNonMatchingValues($structure);
         $matchingValues = array_diff($this->values, $nonMatchingValues);
         if (!empty($matchingValues)) {
             $matchingVariants[$path] = $matchingValues;
         }
     }
     if (empty($matchingVariants)) {
         return TRUE;
     }
     $matchingMessage = '';
     foreach ($matchingVariants as $path => $matchingValues) {
         $matchingMessage .= '  * Found in "' . $path . '": ' . implode(', ', $matchingValues);
     }
     $this->sectionFailures[$responseSection->getIdentifier()] = 'Could not assert not having values for "' . $this->table . '.' . $this->field . '"' . LF . $matchingMessage;
     return FALSE;
 }