MergeExtensionConfigurationPassTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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\HttpKernel;
  11. use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
  12. class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testAutoloadMainExtension()
  15. {
  16. $bundles = array(
  17. 'ExtensionAbsentBundle' => 'Symfony\\Tests\\Component\\HttpKernel\\Fixtures\\ExtensionAbsentBundle\\ExtensionAbsentBundle',
  18. 'ExtensionLoadedBundle' => 'Symfony\\Tests\\Component\\HttpKernel\\Fixtures\\ExtensionLoadedBundle\\ExtensionLoadedBundle',
  19. 'ExtensionPresentBundle' => 'Symfony\\Tests\\Component\\HttpKernel\\Fixtures\\ExtensionPresentBundle\\ExtensionPresentBundle',
  20. );
  21. $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
  22. $params = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag');
  23. $container->expects($this->once())
  24. ->method('getParameter')
  25. ->with('kernel.bundles')
  26. ->will($this->returnValue($bundles));
  27. $container->expects($this->exactly(2))
  28. ->method('getExtensionConfig')
  29. ->will($this->returnCallback(function($name) {
  30. switch ($name) {
  31. case 'extension_present':
  32. return array();
  33. case 'extension_loaded':
  34. return array(array());
  35. }
  36. }));
  37. $container->expects($this->once())
  38. ->method('loadFromExtension')
  39. ->with('extension_present', array());
  40. $container->expects($this->any())
  41. ->method('getParameterBag')
  42. ->will($this->returnValue($params));
  43. $params->expects($this->any())
  44. ->method('all')
  45. ->will($this->returnValue(array()));
  46. $container->expects($this->any())
  47. ->method('getDefinitions')
  48. ->will($this->returnValue(array()));
  49. $container->expects($this->any())
  50. ->method('getAliases')
  51. ->will($this->returnValue(array()));
  52. $container->expects($this->any())
  53. ->method('getExtensions')
  54. ->will($this->returnValue(array()));
  55. $configPass = new MergeExtensionConfigurationPass();
  56. $configPass->process($container);
  57. }
  58. }