Пример #1
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']);
 }
Пример #2
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']);
 }
Пример #3
0
 /**
  * @param array $mapSchema
  * @return Map
  */
 public static function create(array $mapSchema)
 {
     $map = new Map();
     foreach ($mapSchema as $key => $value) {
         $tags = [];
         if (strpos($key, ':') !== false) {
             list($key, $tags) = explode(':', $key);
             $tags = self::normaliseTags($tags);
         }
         $map->add(new MapItem($key, $value, $tags));
     }
     return $map;
 }
Пример #4
0
 function add($map)
 {
     $this->map = Map::add($this->map, $map, $this->options);
 }