예제 #1
0
파일: SimpleMapTest.php 프로젝트: fwk/xml
 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
파일: MapTest.php 프로젝트: fwk/xml
 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);
 }