2010-03-18 07:48:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2010-04-25 16:06:54 +01:00
|
|
|
* This file is part of the Symfony package.
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-04-07 02:07:59 +01:00
|
|
|
*
|
2010-03-18 07:48:03 +00:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
namespace Symfony\Tests\Component\DependencyInjection\Dumper;
|
2010-03-18 07:48:03 +00:00
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
use Symfony\Component\DependencyInjection\Dumper\GraphvizDumper;
|
2010-03-18 07:48:03 +00:00
|
|
|
|
|
|
|
class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2012-07-09 13:38:28 +01:00
|
|
|
protected static $fixturesPath;
|
2010-05-06 12:25:53 +01:00
|
|
|
|
2012-07-09 13:38:28 +01:00
|
|
|
public static function setUpBeforeClass()
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2010-06-28 08:31:54 +01:00
|
|
|
self::$fixturesPath = __DIR__.'/../Fixtures/';
|
2010-05-06 12:25:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDump()
|
|
|
|
{
|
2010-07-15 14:11:33 +01:00
|
|
|
$dumper = new GraphvizDumper($container = new ContainerBuilder());
|
2010-05-06 12:25:53 +01:00
|
|
|
|
|
|
|
$this->assertStringEqualsFile(self::$fixturesPath.'/graphviz/services1.dot', $dumper->dump(), '->dump() dumps an empty container as an empty dot file');
|
|
|
|
|
|
|
|
$container = include self::$fixturesPath.'/containers/container9.php';
|
|
|
|
$dumper = new GraphvizDumper($container);
|
|
|
|
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services9.dot')), $dumper->dump(), '->dump() dumps services');
|
|
|
|
|
|
|
|
$container = include self::$fixturesPath.'/containers/container10.php';
|
|
|
|
$dumper = new GraphvizDumper($container);
|
|
|
|
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10.dot')), $dumper->dump(), '->dump() dumps services');
|
|
|
|
|
|
|
|
$container = include self::$fixturesPath.'/containers/container10.php';
|
|
|
|
$dumper = new GraphvizDumper($container);
|
|
|
|
$this->assertEquals($dumper->dump(array(
|
|
|
|
'graph' => array('ratio' => 'normal'),
|
|
|
|
'node' => array('fontsize' => 13, 'fontname' => 'Verdana', 'shape' => 'square'),
|
|
|
|
'edge' => array('fontsize' => 12, 'fontname' => 'Verdana', 'color' => 'white', 'arrowhead' => 'closed', 'arrowsize' => 1),
|
|
|
|
'node.instance' => array('fillcolor' => 'green', 'style' => 'empty'),
|
|
|
|
'node.definition' => array('fillcolor' => 'grey'),
|
|
|
|
'node.missing' => array('fillcolor' => 'red', 'style' => 'empty'),
|
|
|
|
)), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10-1.dot')), '->dump() dumps services');
|
|
|
|
}
|
2010-03-18 07:48:03 +00:00
|
|
|
}
|