/** * @param PreTransactionEvent $event * */ public function onPreTransaction(PreTransactionEvent $event) { $transaction = $event->getTransaction(); $uri = $transaction->getUri()->withQuery('api_token=' . $this->token); $transaction = $transaction->withUri($uri); $event->setTransaction($transaction); }
/** * Test Transaction * * @author Florian Preusner * @version 4.5 * @since 2016-01 * * @covers EightPoints\Bundle\GuzzleBundle\Events\PreTransactionEvent::setTransaction * @covers EightPoints\Bundle\GuzzleBundle\Events\PreTransactionEvent::getTransaction */ public function testTranscation() { $method = 'POST'; $request = $this->getMockBuilder('GuzzleHttp\\Psr7\\Request')->setConstructorArgs(array('GET', '/'))->getMock(); $preEvent = new PreTransactionEvent($request, null); $transMock = $this->getMockBuilder('GuzzleHttp\\Psr7\\Request')->setConstructorArgs(array($method, '/'))->getMock(); $transMock->method('getMethod')->willReturn($method); $preEvent->setTransaction($transMock); $transaction = $preEvent->getTransaction(); $this->assertSame($transaction, $transMock); $this->assertSame($method, $transaction->getMethod()); }