/** * @depends testGet * @param ArrayPath * @return void */ public function testSet(ArrayPath $arrayPathObject) { $arrayPathObject->set('setting.template.title', 'Titel'); $arrayPathObject->set('setting.database.pass', 'Kennwort'); $this->assertEquals('Kennwort', $arrayPathObject->get('setting.database.pass')); $this->assertEquals('framework.html', $arrayPathObject->get('setting.template.file')); $this->assertEquals('Titel', $arrayPathObject->get('setting.template.title')); $this->assertInternalType('array', $arrayPathObject->get('setting.database')); $this->assertEquals(3, count($arrayPathObject->get('setting.database'))); $this->assertInternalType('array', $arrayPathObject->get('setting.template')); $this->assertEquals(2, count($arrayPathObject->get('setting.template'))); }
<?php use Naucon\Utility\ArrayPath; $array = array(); $array['setting']['database']['name'] = 'tipp'; $array['setting']['database']['user'] = '******'; $array['setting']['database']['pass'] = '******'; $array['setting']['template']['file'] = 'framework.html'; $arrayPathObject = new ArrayPath($array); $arrayPathObject->set('setting.template.title', 'Titel'); $arrayPathObject->set('setting.database.pass', 'Kennwort'); var_dump($arrayPathObject->get()); var_dump($arrayPathObject->get('setting.database'));