예제 #1
0
 public function testCanSetRequest()
 {
     $command = $this->getMock('GuzzleHttp\\Command\\CommandInterface');
     $client = $this->getMock('GuzzleHttp\\Command\\ServiceClientInterface');
     $trans = new CommandTransaction($client, $command);
     $event = new PrepareEvent($trans);
     $request = new Request('GET', 'http://httbin.org');
     $event->setRequest($request);
     $this->assertSame($request, $event->getRequest());
     $this->assertFalse($event->isPropagationStopped());
 }
예제 #2
0
 public function onPrepare(PrepareEvent $event)
 {
     // Don't modify the request if one is already present
     if ($event->getRequest()) {
         return;
     }
     /* @var GuzzleCommandInterface $command */
     $command = $event->getCommand();
     /* @var GuzzleClientInterface $client */
     $client = $event->getClient();
     $request = $this->createRequest($command, $client);
     $this->prepareRequest($command, $client, $request);
     $event->setRequest($request);
 }