You are here

function DrupalSolrOfflineWebTestCase::_nestedCompare in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 tests/apachesolr_base.test \DrupalSolrOfflineWebTestCase::_nestedCompare()
  2. 6.3 tests/apachesolr_base.test \DrupalSolrOfflineWebTestCase::_nestedCompare()
1 call to DrupalSolrOfflineWebTestCase::_nestedCompare()
DrupalSolrOfflineEnvironmentWebTestCase::testCloneSearchEnvironment in tests/apachesolr_base.test
Asserts that we can clone a search environment

File

tests/apachesolr_base.test, line 4
Unit test class that provides tests for base functionality of the Apachesolr Module without having the need of a Solr Server

Class

DrupalSolrOfflineWebTestCase

Code

function _nestedCompare($a1, $a2) {
  if (count($a1) != count($a2)) {

    //$extra1 = array_diff_key($a1, $a2);

    //$extra2 = array_diff_key($a2, $a1);

    //$extra = '';

    //if ($extra1) {

    //  $extra .= ' Extra keys in $a1: ' . implode(', ', array_keys($extra1));

    //}

    //if ($extra2) {

    //  $extra .= ' Extra keys in $a2: ' . implode(', ', array_keys($extra2));

    //}

    //debug('count($a1) != count($a2) :' . $extra);
    return FALSE;
  }
  foreach ($a1 as $k => $v) {
    if (!isset($a2[$k])) {

      //debug("\$a2[$k] is not set");
      return FALSE;
    }
    if (is_array($a1[$k]) && is_array($a2[$k])) {
      if (!$this
        ->_nestedCompare($a1[$k], $a2[$k])) {

        //debug("_nestedCompare(\$a1[$k], \$a2[$k]) is false");
        return FALSE;
      }
    }
    elseif ($a1[$k] !== $a2[$k]) {

      //debug("\$a1[$k] !== \$a2[$k] : " . var_export($a1[$k], TRUE) . " " . var_export($a2[$k], TRUE));
      return FALSE;
    }
  }
  return TRUE;
}