Merge pull request #146 from cedriclombardot/1.1-feat-php-yaml
Enable php in yaml fixtures
This commit is contained in:
commit
a93ea28f32
2 changed files with 34 additions and 0 deletions
|
|
@ -19,6 +19,16 @@ use Symfony\Component\Yaml\Yaml;
|
|||
*/
|
||||
class YamlDataLoader extends AbstractDataLoader
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($rootDir)
|
||||
{
|
||||
parent::__construct($rootDir);
|
||||
|
||||
Yaml::enablePhpParsing(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -135,4 +135,28 @@ YAML;
|
|||
$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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue