Skip to content

Commit

Permalink
fixed using deprecated yaml parser method.
Browse files Browse the repository at this point in the history
  • Loading branch information
congpeijun committed Mar 2, 2015
1 parent b54d9a1 commit d9b1bf7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/LinkORB/Transmogrifier/Dataset.php
Expand Up @@ -3,6 +3,7 @@
namespace LinkORB\Transmogrifier;

use LinkORB\Transmogrifier\Database;
use LinkORB\Transmogrifier\Parser\YamlParser;

class Dataset
{
Expand Down Expand Up @@ -50,7 +51,7 @@ public function loadDatasetFile($filename, $format = '')
break;
case "yml":
case "yaml":
$ds = new \PHPUnit_Extensions_Database_DataSet_YamlDataSet($filename);
$ds = new \PHPUnit_Extensions_Database_DataSet_YamlDataSet($filename, new YamlParser());
break;
case "xml":
$ds = new \PHPUnit_Extensions_Database_DataSet_XmlDataSet($filename);
Expand Down
24 changes: 24 additions & 0 deletions src/LinkORB/Transmogrifier/Parser/YamlParser.php
@@ -0,0 +1,24 @@
<?php
namespace LinkORB\Transmogrifier\Parser;

use PHPUnit_Extensions_Database_DataSet_IYamlParser;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;

class YamlParser implements PHPUnit_Extensions_Database_DataSet_IYamlParser
{
/**
* @param string $yamlFile
* @return array parsed YAML
*/
public function parseYaml($yamlFile)
{
$yaml = new Parser();
try {
$value = $yaml->parse(file_get_contents($yamlFile));
} catch (ParseException $e) {
throw $e;
}
return $value;
}
}

0 comments on commit d9b1bf7

Please sign in to comment.