EventDispatcherTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Script;
  12. use Exception;
  13. use Composer\Test\TestCase;
  14. use Composer\Script\Event;
  15. use Composer\Script\EventDispatcher;
  16. /**
  17. *
  18. * @group
  19. * @ticket #693
  20. * @author Andrea Turso <turso@officinesoftware.co.uk>
  21. */
  22. class EventDispatcherTest extends TestCase
  23. {
  24. /**
  25. * @expectedException \RuntimeException
  26. */
  27. public function testListenerExceptionsAreSuppressed()
  28. {
  29. $dispatcher = $this->getDispatcherStubForListenersTest(array(
  30. "Composer\Test\Script\EventDispatcherTest::call"
  31. ));
  32. $dispatcher->dispatchCommandEvent("post-install-cmd");
  33. }
  34. private function getDispatcherStubForListenersTest($listeners)
  35. {
  36. $dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
  37. ->setConstructorArgs(array(
  38. $this->getMock('Composer\Composer'),
  39. $this->getMock('Composer\IO\IOInterface')))
  40. ->setMethods(array('getListeners'))
  41. ->getMock();
  42. $dispatcher->expects($this->atLeastOnce())
  43. ->method('getListeners')
  44. ->will($this->returnValue($listeners));
  45. return $dispatcher;
  46. }
  47. public static function call()
  48. {
  49. throw new Exception();
  50. }
  51. }