[Tests] Added a test for the Yaml dumper
This commit is contained in:
parent
aa3c07d1a8
commit
0a05b56e64
57
Tests/DataFixtures/Dumper/YamlDataDumperTest.php
Normal file
57
Tests/DataFixtures/Dumper/YamlDataDumperTest.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the PropelBundle package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Propel\PropelBundle\Tests\DataFixtures\Dumper;
|
||||
|
||||
use Propel\PropelBundle\Tests\TestCase;
|
||||
use Propel\PropelBundle\DataFixtures\Dumper\YamlDataDumper;
|
||||
|
||||
/**
|
||||
* @author William Durand <william.durand1@gmail.com>
|
||||
*/
|
||||
class YamlDataDumperTest extends TestCase
|
||||
{
|
||||
public function testTransformArrayToData()
|
||||
{
|
||||
$expected = <<<YML
|
||||
\Foo\Bar:
|
||||
fb1:
|
||||
Id: 10
|
||||
Title: Hello
|
||||
fb2:
|
||||
Id: 20
|
||||
Title: World
|
||||
|
||||
YML;
|
||||
|
||||
$array = array(
|
||||
'\Foo\Bar' => array(
|
||||
'fb1' => array('Id' => 10, 'Title' => 'Hello'),
|
||||
'fb2' => array('Id' => 20, 'Title' => 'World')
|
||||
)
|
||||
);
|
||||
|
||||
$loader = new TestableYamlDataDumper();
|
||||
$result = $loader->transformArrayToData($array);
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
}
|
||||
|
||||
class TestableYamlDataDumper extends YamlDataDumper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function transformArrayToData($array)
|
||||
{
|
||||
return parent::transformArrayToData($array);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue