public function testCommandEvent()
 {
     $pheanstalk = $this->getMockForAbstractClass(PheanstalkInterface::class);
     $payload = ['foo'];
     $event = new CommandEvent($pheanstalk, $payload);
     $this->assertSame($pheanstalk, $event->getPheanstalk());
     $this->assertSame($payload, $event->getPayload());
 }
 /**
  * @param CommandEvent $event
  * @param string       $eventName
  */
 public function onCommand(CommandEvent $event, $eventName)
 {
     if (!$this->logger) {
         return;
     }
     $pheanstalk = $event->getPheanstalk();
     $connection = $pheanstalk->getConnection();
     if (!$connection->isServiceListening()) {
         $this->logger->warning('Pheanstalk connection isn\'t listening');
     }
     $pheanstalkName = 'unknown';
     if ($pheanstalk instanceof PheanstalkProxyInterface) {
         $pheanstalkName = $pheanstalk->getName();
     }
     $nameExploded = explode('.', $eventName);
     $this->logger->info('Pheanstalk command: ' . $nameExploded[count($nameExploded) - 1], ['payload' => $event->getPayload(), 'pheanstalk' => $pheanstalkName]);
 }