merge() public static méthode

On duplicate keys, the value in $array will overwrite the value stored in the options.
public static merge ( array $array )
$array array Associative array of options to merge into the existing options.
 public function testQPMerge()
 {
     $options = array('test1' => 'val1', 'test2' => 'val2');
     $options2 = array('test1' => 'val3', 'test4' => 'val4');
     Options::set($options);
     Options::merge($options2);
     $results = Options::get();
     $this->assertTrue(Options::has('test4'));
     $this->assertEquals('val3', $results['test1']);
 }
Exemple #2
0
 public function testIgnoreParserWarnings()
 {
     $qp = @qp('<html><body><b><i>BAD!</b></i></body>', NULL, array('ignore_parser_warnings' => TRUE));
     $this->assertTrue(strpos($qp->html(), '<i>BAD!</i>') !== FALSE);
     \QueryPath\Options::merge(array('ignore_parser_warnings' => TRUE));
     $qp = @qp('<html><body><b><i>BAD!</b></i></body>');
     $this->assertTrue(strpos($qp->html(), '<i>BAD!</i>') !== FALSE);
     $qp = @qp('<html><body><blarg>BAD!</blarg></body>');
     $this->assertTrue(strpos($qp->html(), '<blarg>BAD!</blarg>') !== FALSE, $qp->html());
     \QueryPath\Options::set(array());
     // Reset to empty options.
 }