assertSame($result, simple_template($template, $keys)); } public function providerSimpleTemplate() { $return = array( // One line php-style comments array( '

{{title}}

// just something interesting... #or ^not...', array('title' => 'A Comedy of Errors'), '

A Comedy of Errors

' ), // Multiline php-style comments array( '/** * just something interesting... #or ^not... */

{{title}}

/** * just something interesting... #or ^not... */', array('title' => 'A Comedy of Errors'), '

A Comedy of Errors

'.PHP_EOL ), // Var not exist array( '

{{title}}

', array('non_exist' => 'A Comedy of Errors'), '

' ), ); $templates_dir = dirname(__FILE__) . '/templates'; foreach (scandir($templates_dir) as $dir) { $json = $templates_dir.'/'.$dir.'/'.$dir.'.json'; if ($dir != '.' && $dir != '..' && is_dir($templates_dir.'/'.$dir) && is_file($json)) { $template = $templates_dir.'/'.$dir.'/'.$dir.'.mustache'; $result = $templates_dir.'/'.$dir.'/'.$dir.'.txt'; $return[] = array( file_get_contents($template), json_decode(file_get_contents($json), TRUE), file_get_contents($result) ); } } return $return; } /** * @dataProvider providerArrayToXML * @group templates */ public function testArrayToXML($array, $result) { $xml = new SimpleXMLElement('