title: Functional Testing Events and Subscribers in Symfony 4
body: <p>I need to functionally test the a subscriber in Symfony 4 and I'm having problems finding how. The Subscriber has the following structure </p>
  
  <pre><code>/**
  * Class ItemSubscriber
  */
  class ItemSubscriber implements EventSubscriberInterface
  {
      /**
       * @var CommandBus
       */
      protected $commandBus;
  
      /**
       * Subscriber constructor.
       *
       * @param CommandBus $commandBus
       */
      public function __construct(CommandBus $commandBus)
      {
          $this-&gt;commandBus = $commandBus;
      }
  
      /**
       * {@inheritdoc}
       */
      public static function getSubscribedEvents()
      {
          return [
              CommandFailedEvent::NAME =&gt; 'onCommandFailedEvent',
          ];
      }
  
      /**
       * @param CommandFailedEvent $event
       *
       * @throws Exception
       */
      public function onCommandFailedEvent(CommandFailedEvent $event)
      {
          $item = $event-&gt;getItem();
          $this-&gt;processFailed($item);
      }
  
      /**
       * Sends message 
       *
       * @param array $item
       *
       * @throws Exception
       */
      private function processFailed(array $item)
      {
          $this-&gt;commandBus-&gt;handle(new UpdateCommand($item));
      }
  }
  </code></pre>
  
  <p>The flow of the subscriber is receiving an internal event and send a message by rabbit through the command bus to another project.</p>
  
  <p>How can I test that dispatching the event <code>CommandFailedEvent</code> the line in <code>processFailed(array $item)</code> is executed?</p>
  
  <p>Does anyone has documentation on best practices to test Events and Subscribers in Symfony 4?</p>