GraphvizDumperTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\DependencyInjection\Dumper;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Dumper\GraphvizDumper;
  13. class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
  14. {
  15. static protected $fixturesPath;
  16. static public function setUpBeforeClass()
  17. {
  18. self::$fixturesPath = __DIR__.'/../Fixtures/';
  19. }
  20. public function testDump()
  21. {
  22. $dumper = new GraphvizDumper($container = new ContainerBuilder());
  23. $this->assertStringEqualsFile(self::$fixturesPath.'/graphviz/services1.dot', $dumper->dump(), '->dump() dumps an empty container as an empty dot file');
  24. $container = include self::$fixturesPath.'/containers/container9.php';
  25. $dumper = new GraphvizDumper($container);
  26. $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services9.dot')), $dumper->dump(), '->dump() dumps services');
  27. $container = include self::$fixturesPath.'/containers/container10.php';
  28. $dumper = new GraphvizDumper($container);
  29. $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10.dot')), $dumper->dump(), '->dump() dumps services');
  30. $container = include self::$fixturesPath.'/containers/container10.php';
  31. $dumper = new GraphvizDumper($container);
  32. $this->assertEquals($dumper->dump(array(
  33. 'graph' => array('ratio' => 'normal'),
  34. 'node' => array('fontsize' => 13, 'fontname' => 'Verdana', 'shape' => 'square'),
  35. 'edge' => array('fontsize' => 12, 'fontname' => 'Verdana', 'color' => 'white', 'arrowhead' => 'closed', 'arrowsize' => 1),
  36. 'node.instance' => array('fillcolor' => 'green', 'style' => 'empty'),
  37. 'node.definition' => array('fillcolor' => 'grey'),
  38. 'node.missing' => array('fillcolor' => 'red', 'style' => 'empty'),
  39. )), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10-1.dot')), '->dump() dumps services');
  40. }
  41. }