/**
  * Test function epArraySet() in epUtils.php
  */
 function test_epArraySet()
 {
     // make sure method exists
     $this->assertTrue(function_exists('epArraySet'));
     // array to be tested
     $array = array('a' => array('b' => array('c' => array('d' => 'x'))));
     // test assignment on reference (fails now, could be a php bug!)
     $x = md5($array['a']['b']['c']['d']);
     epArraySet($array, 'a.b.c.d', $x);
     $this->assertTrue($x == $array['a']['b']['c']['d']);
     // again
     $x = md5($array['a']['b']['c']['d']);
     epArraySet($array, 'a.b.c.d', $x);
     $this->assertTrue($x == $array['a']['b']['c']['d']);
 }
Example #2
0
 /**
  * Sets (changes) value to a configuration option
  * 
  * The name of an option can be given in a namespace ('a.b.c.d') 
  * or xpath ('a/b/c/d') format so the caller can reach any level 
  * of the option hierarchy. See {@link epArraySet()}.
  * 
  * @param string name of option
  * @param mixed value of option
  * @return bool
  * @access public
  */
 public function set($name, $value)
 {
     // sanity check
     if (!$name) {
         return false;
     }
     // if $value is an instance of epConfig, get its option
     // array so to internally maintain options in an array
     if ($value instanceof epConfig) {
         $value = $value->options();
     }
     // set name->value in array
     if (!($this->options = epArraySet($this->options, $name, $value))) {
         return false;
     }
     return true;
 }