ResolvePrivatesPassTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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\Compiler;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\DependencyInjection\Compiler\ResolvePrivatesPass;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. class ResolvePrivatesPassTest extends TestCase
  15. {
  16. public function testPrivateHasHigherPrecedenceThanPublic()
  17. {
  18. $container = new ContainerBuilder();
  19. $container->register('foo', 'stdClass')
  20. ->setPublic(true)
  21. ->setPrivate(true)
  22. ;
  23. $container->setAlias('bar', 'foo')
  24. ->setPublic(false)
  25. ->setPrivate(false)
  26. ;
  27. (new ResolvePrivatesPass())->process($container);
  28. $this->assertFalse($container->getDefinition('foo')->isPublic());
  29. $this->assertFalse($container->getAlias('bar')->isPublic());
  30. }
  31. }