Skip to content

Commit f7b97f7

Browse files
committed
Make Gateway purchase() method optional
1 parent 6d48341 commit f7b97f7

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

src/Omnipay/Common/AbstractGateway.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ public function supportsCapture()
130130
return method_exists($this, 'capture');
131131
}
132132

133+
/**
134+
* Supports Purchase
135+
*
136+
* @return boolean True if this gateway supports the purchase() method
137+
*/
138+
public function supportsPurchase()
139+
{
140+
return method_exists($this, 'purchase');
141+
}
142+
133143
/**
134144
* Supports Complete Purchase
135145
*

src/Omnipay/Common/GatewayInterface.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,4 @@ public function initialize(array $parameters = array());
4444
* @return array
4545
*/
4646
public function getParameters();
47-
48-
/**
49-
* Create a new charge (combined authorize + capture).
50-
*
51-
* @param array $parameters An array of options
52-
*
53-
* @return \Omnipay\Common\Message\RequestInterface
54-
*/
55-
public function purchase(array $parameters = array());
5647
}

tests/Omnipay/Common/AbstractGatewayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AbstractGatewayTest extends TestCase
99
{
1010
public function setUp()
1111
{
12-
$this->gateway = m::mock("\Omnipay\Common\AbstractGateway[getName,getDefaultParameters,purchase]");
12+
$this->gateway = m::mock("\Omnipay\Common\AbstractGateway")->makePartial();
1313
}
1414

1515
public function testGetShortName()

tests/Omnipay/Common/Message/AbstractRequestTest.php

Lines changed: 1 addition & 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,sendData]');
14+
$this->request = m::mock('\Omnipay\Common\Message\AbstractRequest')->makePartial();
1515
$this->request->initialize();
1616
}
1717

tests/Omnipay/Common/Message/AbstractResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AbstractResponseTest extends TestCase
99
{
1010
public function testDefaultMethods()
1111
{
12-
$response = m::mock('\Omnipay\Common\Message\AbstractResponse[isSuccessful]');
12+
$response = m::mock('\Omnipay\Common\Message\AbstractResponse')->makePartial();
1313

1414
$this->assertFalse($response->isRedirect());
1515
$this->assertNull($response->getData());
@@ -23,7 +23,7 @@ public function testDefaultMethods()
2323
*/
2424
public function testCannotRedirectResponseThatIsNotRedirectResponseInterface()
2525
{
26-
$response = m::mock('\Omnipay\Common\Message\AbstractResponse[isSuccessful,isRedirect]');
26+
$response = m::mock('\Omnipay\Common\Message\AbstractResponse')->makePartial();
2727

2828
$response->getRedirectResponse();
2929
}

0 commit comments

Comments
 (0)