예제 #1
0
 protected function _doConvertPlugin($plugin_id, $params = '', $body = '', $special_attr = '', $whole_match = '')
 {
     if ($params !== '') {
         $params = YamlParams::parse($params);
     } else {
         $params = array();
     }
     $body = $this->unHash($body);
     try {
         $plugin = $this->loadPlugin($plugin_id);
         if ($plugin instanceof SpecialAttributeInterface && $special_attr !== '') {
             $attrs = $this->parseSpecialAttribute($special_attr);
             foreach ($attrs as $attr => $value) {
                 if (empty($value)) {
                     continue;
                 }
                 $method = 'setSpecial' . ucfirst($attr) . 'Attribute';
                 $plugin->{$method}($value);
             }
         }
         $result = $plugin->convert($params, $body);
         return "\n\n" . $this->hashBlock($result) . "\n\n";
     } catch (\RuntimeException $e) {
     } catch (\InvalidArgumentException $e) {
     }
     return $whole_match;
 }
예제 #2
0
 /**
  * @dataProvider textProvider
  */
 public function testText($text, $expected)
 {
     $yaml = YamlParams::adjustAsFlow($text);
     $result = Yaml::parse($yaml);
     $this->assertEquals($expected, $result);
 }