public function testHasData() { $client = $this->getMockForAbstractClass('GuzzleHttp\\Command\\ServiceClientInterface'); $command = new Command('foo', []); $trans = new CommandTransaction($client, $command, ['foo' => 'bar']); $this->assertSame($client, $trans->getClient()); $this->assertSame($command, $trans->getCommand()); $this->assertSame('bar', $trans->getContext()->get('foo')); $this->assertNull($trans->getResult()); $this->assertNull($trans->getResponse()); $this->assertNull($trans->getRequest()); $this->assertNull($trans->getException()); }
/** * Emits an error event for the command. * * @param CommandTransaction $trans Command execution context * @param \Exception $e Exception encountered * @throws \Exception */ public static function emitError(CommandTransaction $trans, \Exception $e) { $trans->setException($e); // If this exception has already emitted, then throw it now. if (isset($e->_emittedError)) { throw $e; } $e->_emittedError = true; $event = new CommandErrorEvent($trans); $trans->getCommand()->getEmitter()->emit('error', $event); if (!$event->isPropagationStopped()) { throw $e; } }
/** * Get the command associated with the event * * @return CommandInterface */ public function getCommand() { return $this->trans->getCommand(); }
/** * Prepare a command using the provided options. */ private function prepare(CommandTransaction $trans) { $this->attachListeners($trans->getCommand(), $this->eventListeners); CommandEvents::prepare($trans); }