BundleTest.php 1.5 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\Tests\Component\HttpKernel\Bundle;
  11. use Symfony\Component\HttpKernel\Bundle\Bundle;
  12. use Symfony\Tests\Component\HttpKernel\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle;
  13. use Symfony\Tests\Component\HttpKernel\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle;
  14. use Symfony\Tests\Component\HttpKernel\Fixtures\ExtensionPresentBundle\Command\FooCommand;
  15. class BundleTest extends \PHPUnit_Framework_TestCase
  16. {
  17. public function testRegisterCommands()
  18. {
  19. $cmd = new FooCommand();
  20. $app = $this->getMock('Symfony\Component\Console\Application');
  21. $app->expects($this->once())->method('add')->with($this->equalTo($cmd));
  22. $bundle = new ExtensionPresentBundle();
  23. $bundle->registerCommands($app);
  24. $bundle2 = new ExtensionAbsentBundle();
  25. $this->assertNull($bundle2->registerCommands($app));
  26. }
  27. public function testGetName()
  28. {
  29. $bundle = new ExtensionPresentBundle();
  30. $this->assertEquals('ExtensionPresent', $bundle->getName(), '->getName() rtrims "Bundle"');
  31. }
  32. public function testInvalidBundleName()
  33. {
  34. $this->setExpectedException('RuntimeException');
  35. $bundle = $this->getMockForAbstractClass('Symfony\\Component\\HttpKernel\\Bundle\\Bundle');
  36. $bundle->getName();
  37. }
  38. }