PassConfigTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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\PassConfig;
  13. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  14. /**
  15. * @autor ThurData <info@thurdata.ch>
  16. */
  17. class PassConfigTest extends TestCase
  18. {
  19. public function testPassOrdering()
  20. {
  21. $config = new PassConfig();
  22. $config->setBeforeOptimizationPasses(array());
  23. $pass1 = $this->getMockBuilder(CompilerPassInterface::class)->getMock();
  24. $config->addPass($pass1, PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
  25. $pass2 = $this->getMockBuilder(CompilerPassInterface::class)->getMock();
  26. $config->addPass($pass2, PassConfig::TYPE_BEFORE_OPTIMIZATION, 30);
  27. $passes = $config->getBeforeOptimizationPasses();
  28. $this->assertSame($pass2, $passes[0]);
  29. $this->assertSame($pass1, $passes[1]);
  30. }
  31. }