BundleTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\Component\HttpKernel\Tests\Bundle;
  11. use Symfony\Component\HttpKernel\Bundle\Bundle;
  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 testRegisterCommands()
  18. {
  19. if (!class_exists('Symfony\Component\Console\Application')) {
  20. $this->markTestSkipped('The "Console" component is not available');
  21. }
  22. if (!interface_exists('Symfony\Component\DependencyInjection\ContainerAwareInterface')) {
  23. $this->markTestSkipped('The "DependencyInjection" component is not available');
  24. }
  25. if (!class_exists('Symfony\Component\Finder\Finder')) {
  26. $this->markTestSkipped('The "Finder" component is not available');
  27. }
  28. $cmd = new FooCommand();
  29. $app = $this->getMock('Symfony\Component\Console\Application');
  30. $app->expects($this->once())->method('add')->with($this->equalTo($cmd));
  31. $bundle = new ExtensionPresentBundle();
  32. $bundle->registerCommands($app);
  33. $bundle2 = new ExtensionAbsentBundle();
  34. $this->assertNull($bundle2->registerCommands($app));
  35. }
  36. }