BundleTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\HttpKernel\Tests\Bundle;
  11. use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle;
  12. use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle;
  13. use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle;
  14. use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand;
  15. class BundleTest extends \PHPUnit_Framework_TestCase
  16. {
  17. public function testGetContainerExtension()
  18. {
  19. $bundle = new ExtensionPresentBundle();
  20. $this->assertInstanceOf(
  21. 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\DependencyInjection\ExtensionPresentExtension',
  22. $bundle->getContainerExtension()
  23. );
  24. }
  25. public function testRegisterCommands()
  26. {
  27. $cmd = new FooCommand();
  28. $app = $this->getMock('Symfony\Component\Console\Application');
  29. $app->expects($this->once())->method('add')->with($this->equalTo($cmd));
  30. $bundle = new ExtensionPresentBundle();
  31. $bundle->registerCommands($app);
  32. $bundle2 = new ExtensionAbsentBundle();
  33. $this->assertNull($bundle2->registerCommands($app));
  34. }
  35. /**
  36. * @expectedException \LogicException
  37. * @expectedExceptionMessage must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface
  38. */
  39. public function testGetContainerExtensionWithInvalidClass()
  40. {
  41. $bundle = new ExtensionNotValidBundle();
  42. $bundle->getContainerExtension();
  43. }
  44. }