public function testMerge() { $this->assertEmpty(ArrayUtils::merge(array())); $this->assertEmpty(ArrayUtils::merge(array(), array(), array(), array(), array())); $allOptions = array('lorem' => 'ipsum', 'dolor' => 'sit', 'amet' => 'adipiscit', 'elit' => true, 'list' => array(), 'default_list' => array('item1' => 0, 'item2' => 3, 'item3' => 5)); $appOptions = array('lorem' => false, 'dolor' => 'whatever', 'sit' => true, 'list' => array('item4' => 'yes', 'item5' => 'no', 'item6' => 'maybe')); $userOptions = array('lorem' => true, 'amet' => 'lipsum', 'list' => array('item5' => 'yes')); $result = array('lorem' => true, 'dolor' => 'whatever', 'amet' => 'lipsum', 'sit' => true, 'elit' => true, 'list' => array('item4' => 'yes', 'item5' => 'yes', 'item6' => 'maybe'), 'default_list' => array('item1' => 0, 'item2' => 3, 'item3' => 5)); $this->assertEquals(ArrayUtils::merge($allOptions, $appOptions, $userOptions), $result); $this->assertEquals(ArrayUtils::merge(array(0, 1, 2, 3, 4, 5, 6, 7), array('a', 'b', 'c', 'd')), array(0, 1, 2, 3, 4, 5, 6, 7, 'a', 'b', 'c', 'd')); $mixedResult = array(0, 1, 2, 3, array('id' => 1, 'name' => 'lorem', 'categoryId' => 5, 'date' => '2013.07.08'), array('id' => 2, 'name' => 'ipsum', 'categoryId' => 3, 'date' => '2013.07.07'), array('id' => 5, 'name' => 'dolor', 'categoryId' => 1, 'date' => '2012.07.08'), array('id' => 6, 'name' => 'sit', 'categoryId' => 3, 'date' => '2013.12.08'), array('id' => 9, 'name' => 'amet', 'categoryId' => 5, 'date' => '2013.10.14'), 'a', 'b', 'c', 'd'); $this->assertEquals(ArrayUtils::merge(array(0, 1, 2, 3), $this->_getArrayPreset('2D_collection_5'), array('a', 'b', 'c', 'd')), $mixedResult); }
/** * Extends the config with the given config. * * @param Config $config Config to read from. * @return bool */ public function extend(Config $config) { $this->config = ArrayUtils::merge($this->config, $config->getNamespace()); $this->loadedFiles = array_merge($this->loadedFiles, $config->getLoadedFiles()); return true; }