public function testQPMerge() { $options = array('test1' => 'val1', 'test2' => 'val2'); $options2 = array('test1' => 'val3', 'test4' => 'val4'); QueryPathOptions::set($options); QueryPathOptions::merge($options2); $results = QueryPathOptions::get(); $this->assertTrue(QueryPathOptions::has('test4')); $this->assertEquals('val3', $results['test1']); }
/** * Merge the provided array with existing options. * * On duplicate keys, the value in $array will overwrite the * value stored in the options. * * @param array $array * Associative array of options to merge into the existing options. */ static function merge($array) { self::$options = $array + self::$options; }
public function testReplaceEntitiesOption() { $path = '<?xml version="1.0"?><root/>'; $xml = qp($path, NULL, array('replace_entities' => TRUE))->xml('<foo>&</foo>')->xml(); $this->assertTrue(strpos($xml, '<foo>&</foo>') !== FALSE); $xml = qp($path, NULL, array('replace_entities' => TRUE))->html('<foo>&</foo>')->xml(); $this->assertTrue(strpos($xml, '<foo>&</foo>') !== FALSE); $xml = qp($path, NULL, array('replace_entities' => TRUE))->xhtml('<foo>&</foo>')->xml(); $this->assertTrue(strpos($xml, '<foo>&</foo>') !== FALSE); QueryPathOptions::set(array('replace_entities' => TRUE)); $this->assertTrue(strpos($xml, '<foo>&</foo>') !== FALSE); QueryPathOptions::set(array()); }