/**
  * test array merge recursive
  *
  * @param array $data
  *
  * @dataProvider arrayDataProvider
  * @requires arrayDataProvider
  */
 public function testArrayMergeRecursive($data)
 {
     static $iteration = 1;
     $merged = ArrayHelper::arrayMergeRecursive($data[0], $data[1], $data[2]);
     $name = 'expectedArrayRecursive' . $iteration;
     $expected = $this->{$name}();
     $this->assertEquals($expected, $merged);
     $iteration++;
 }
Ejemplo n.º 2
0
 /**
  * return original data for key, before it was changed or whole original collection
  * that method don't handle return data preparation
  *
  * @param null|string $key
  * @return mixed
  */
 public function getOriginalCollection($key = null)
 {
     $this->_prepareData($key);
     $data = $this->_removeNewKeys($this->_COLLECTION);
     $collection = [];
     $index = 0;
     for ($i = 0; $i < $this->_originalCollectionSize; $i++) {
         if (in_array($i, $this->_removedKeys)) {
             $collection[$i] = null;
             $index++;
         } else {
             $collection[$i] = $data[$i - $index];
         }
     }
     $mergedData = ArrayHelper::arrayMerge($collection, $this->_originalCollection);
     if (!$key) {
         return $mergedData;
     }
     if (array_key_exists($key, $mergedData)) {
         return $mergedData[$key];
     }
     return null;
 }