Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #146 from cedriclombardot/1.1-feat-php-yaml

Enable php in yaml fixtures
  • Loading branch information...
commit a93ea28f3269b0137ce760ca0ceffd3aa308175b 2 parents c99afb0 + 3b4ce8e
@willdurand willdurand authored
View
10 DataFixtures/Loader/YamlDataLoader.php
@@ -22,6 +22,16 @@ class YamlDataLoader extends AbstractDataLoader
/**
* {@inheritdoc}
*/
+ public function __construct($rootDir)
+ {
+ parent::__construct($rootDir);
+
+ Yaml::enablePhpParsing(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
protected function transformDataToArray($file)
{
return Yaml::parse($file);
View
24 Tests/DataFixtures/Loader/YamlDataLoaderTest.php
@@ -135,4 +135,28 @@ public function testLoadSelfReferencing()
$author = $authors[0];
$this->assertEquals('A famous one', $author->getName());
}
+
+ public function testLoaderWithPhp()
+ {
+ $fixtures = <<<YAML
+Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor:
+ BookAuthor_1:
+ id: '1'
+ name: <?php echo "to be announced"; ?>
+
+YAML;
+ $filename = $this->getTempFile($fixtures);
+
+ $loader = new YamlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader');
+ $loader->load(array($filename), 'default');
+
+ $books = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookPeer::doSelect(new \Criteria(), $this->con);
+ $this->assertCount(0, $books);
+
+ $authors = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthorPeer::doSelect(new \Criteria(), $this->con);
+ $this->assertCount(1, $authors);
+
+ $author = $authors[0];
+ $this->assertEquals('to be announced', $author->getName());
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.