GraphvizDumperTest.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Component\DependencyInjection\Tests\Dumper;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Dumper\GraphvizDumper;
  13. class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
  14. {
  15. protected static $fixturesPath;
  16. public static 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. public function testDumpWithFrozenContainer()
  42. {
  43. $container = include self::$fixturesPath.'/containers/container13.php';
  44. $dumper = new GraphvizDumper($container);
  45. $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services13.dot')), $dumper->dump(), '->dump() dumps services');
  46. }
  47. public function testDumpWithFrozenCustomClassContainer()
  48. {
  49. $container = include self::$fixturesPath.'/containers/container14.php';
  50. $dumper = new GraphvizDumper($container);
  51. $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services14.dot')), $dumper->dump(), '->dump() dumps services');
  52. }
  53. }