Exemple #1
0
 public function testWithRegisteredNamespaces()
 {
     $map = new Maps\Rss();
     $result = $map->execute($this->object);
     $map->add(Path::factory('/rss/channel/feedburner:feedFlare', 'feedFlare')->loop(true));
     $this->assertTrue(is_array($result));
     $this->assertFalse(array_key_exists('feedFlare', $result));
     $map->registerNamespace('feedburner', "http://rssnamespace.org/feedburner/ext/1.0");
     $result2 = $map->execute($this->object);
     $this->assertArrayHasKey('feedFlare', $result2);
 }
Exemple #2
0
 public function testFilteredValue()
 {
     $map = new Map();
     $map->add(Path::factory('/test/description', 'desc')->setDefault('value')->filter(function ($val) {
         return strrev($val);
     }));
     $result = $map->execute($this->object);
     $this->assertTrue(is_array($result));
     $this->assertArrayHasKey('desc', $result);
     $this->assertEquals(strrev("test description"), $result['desc']);
 }
Exemple #3
0
 public function testWrongPath()
 {
     $map = new Map();
     $map->add(Path::factory('/test', 'test')->addChildren(Path::factory('wrong>path', 'wrong', 'defaultFalse')));
     $result = $map->execute(new XmlFile(__DIR__ . '/test.xml'));
     $this->assertTrue(is_array($result));
     $this->assertArrayHasKey('test', $result);
     $this->assertTrue(is_array($result['test']));
     $this->assertArrayHasKey('wrong', $result['test']);
     $this->assertEquals('defaultFalse', $result['test']['wrong']);
 }