GraphvizDumperTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. require_once __DIR__.'/../../../../bootstrap.php';
  10. use Symfony\Components\DependencyInjection\Builder;
  11. use Symfony\Components\DependencyInjection\Dumper\GraphvizDumper;
  12. $t = new LimeTest(4);
  13. $fixturesPath = __DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/';
  14. // ->dump()
  15. $t->diag('->dump()');
  16. $dumper = new GraphvizDumper($container = new Builder());
  17. $t->is($dumper->dump(), file_get_contents($fixturesPath.'/graphviz/services1.dot'), '->dump() dumps an empty container as an empty dot file');
  18. $container = new Builder();
  19. $dumper = new GraphvizDumper($container);
  20. $container = include $fixturesPath.'/containers/container9.php';
  21. $dumper = new GraphvizDumper($container);
  22. $t->is($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents($fixturesPath.'/graphviz/services9.dot')), '->dump() dumps services');
  23. $container = include $fixturesPath.'/containers/container10.php';
  24. $dumper = new GraphvizDumper($container);
  25. $t->is($dumper->dump(), str_replace('%path%', __DIR__, file_get_contents($fixturesPath.'/graphviz/services10.dot')), '->dump() dumps services');
  26. $container = include $fixturesPath.'/containers/container10.php';
  27. $dumper = new GraphvizDumper($container);
  28. $t->is($dumper->dump(array(
  29. 'graph' => array('ratio' => 'normal'),
  30. 'node' => array('fontsize' => 13, 'fontname' => 'Verdana', 'shape' => 'square'),
  31. 'edge' => array('fontsize' => 12, 'fontname' => 'Verdana', 'color' => 'white', 'arrowhead' => 'closed', 'arrowsize' => 1),
  32. 'node.instance' => array('fillcolor' => 'green', 'style' => 'empty'),
  33. 'node.definition' => array('fillcolor' => 'grey'),
  34. 'node.missing' => array('fillcolor' => 'red', 'style' => 'empty'),
  35. )), str_replace('%path%', __DIR__, file_get_contents($fixturesPath.'/graphviz/services10-1.dot')), '->dump() dumps services');