Skip to content

Commit 141ce36

Browse files
committed
Add RequestInterface::sendData() method
1 parent 48922c1 commit 141ce36

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/Omnipay/Common/Message/AbstractRequest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ public function setNotifyUrl($value)
321321
return $this->setParameter('notifyUrl', $value);
322322
}
323323

324+
public function send()
325+
{
326+
$data = $this->getData();
327+
328+
return $this->sendData($data);
329+
}
330+
324331
public function getResponse()
325332
{
326333
if (null === $this->response) {

src/Omnipay/Common/Message/RequestInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,12 @@ public function getResponse();
3232
* @return ResponseInterface
3333
*/
3434
public function send();
35+
36+
/**
37+
* Send the request with specified data
38+
*
39+
* @param mixed $data The data to send
40+
* @return ResponseInterface
41+
*/
42+
public function sendData($data);
3543
}

tests/Omnipay/Common/Message/AbstractRequestTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AbstractRequestTest extends TestCase
1111
{
1212
public function setUp()
1313
{
14-
$this->request = m::mock('\Omnipay\Common\Message\AbstractRequest[getData,send]');
14+
$this->request = m::mock('\Omnipay\Common\Message\AbstractRequest[getData,sendData]');
1515
$this->request->initialize();
1616
}
1717

@@ -261,6 +261,17 @@ public function testNoCurrencyReturnedIfCurrencyNotSet()
261261
$this->assertNull($this->request->getCurrencyNumeric());
262262
}
263263

264+
public function testSend()
265+
{
266+
$response = m::mock('\Omnipay\Common\Message\ResponseInterface');
267+
$data = array('request data');
268+
269+
$this->request->shouldReceive('getData')->once()->andReturn($data);
270+
$this->request->shouldReceive('sendData')->once()->with($data)->andReturn($response);
271+
272+
$this->assertSame($response, $this->request->send());
273+
}
274+
264275
/**
265276
* @expectedException \Omnipay\Common\Exception\RuntimeException
266277
*/

0 commit comments

Comments
 (0)