Skip to content

Commit a1dadb2

Browse files
committed
Rename create/update/delete with a sufix Card, add tests
1 parent a6b188e commit a1dadb2

File tree

2 files changed

+52
-23
lines changed

2 files changed

+52
-23
lines changed

src/Omnipay/Common/AbstractGateway.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,33 +170,33 @@ public function supportsVoid()
170170
}
171171

172172
/**
173-
* Supports Create
173+
* Supports CreateCard
174174
*
175175
* @return boolean True if this gateway supports the create() method
176176
*/
177-
public function supportsCreate()
177+
public function supportsCreateCard()
178178
{
179-
return method_exists($this, 'create');
179+
return method_exists($this, 'createCard');
180180
}
181181

182182
/**
183-
* Supports Delete
183+
* Supports DeleteCard
184184
*
185185
* @return boolean True if this gateway supports the delete() method
186186
*/
187-
public function supportsDelete()
187+
public function supportsDeleteCard()
188188
{
189-
return method_exists($this, 'delete');
189+
return method_exists($this, 'deleteCard');
190190
}
191191

192192
/**
193-
* Supports Update
193+
* Supports UpdateCard
194194
*
195195
* @return boolean True if this gateway supports the update() method
196196
*/
197-
public function supportsUpdate()
197+
public function supportsUpdateCard()
198198
{
199-
return method_exists($this, 'update');
199+
return method_exists($this, 'updateCard');
200200
}
201201

202202
/**

tests/Omnipay/GatewayTestCase.php

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,39 @@ public function testSupportsVoid()
149149
}
150150
}
151151

152-
public function testSupportsCreate()
152+
public function testSupportsCreateCard()
153153
{
154-
$supportsCreate = $this->gateway->supportsCreate();
154+
$supportsCreate = $this->gateway->supportsCreateCard();
155155
$this->assertInternalType('boolean', $supportsCreate);
156156

157157
if ($supportsCreate) {
158-
$this->assertInstanceOf('Omnipay\Common\Message\RequestInterface', $this->gateway->create());
158+
$this->assertInstanceOf('Omnipay\Common\Message\RequestInterface', $this->gateway->createCard());
159159
} else {
160-
$this->assertFalse(method_exists($this->gateway, 'create'));
160+
$this->assertFalse(method_exists($this->gateway, 'createCard'));
161161
}
162162
}
163163

164-
public function testSupportsDelete()
164+
public function testSupportsDeleteCard()
165165
{
166-
$supportsDelete = $this->gateway->supportsDelete();
166+
$supportsDelete = $this->gateway->supportsDeleteCard();
167167
$this->assertInternalType('boolean', $supportsDelete);
168168

169169
if ($supportsDelete) {
170-
$this->assertInstanceOf('Omnipay\Common\Message\RequestInterface', $this->gateway->delete());
170+
$this->assertInstanceOf('Omnipay\Common\Message\RequestInterface', $this->gateway->deleteCard());
171171
} else {
172-
$this->assertFalse(method_exists($this->gateway, 'delete'));
172+
$this->assertFalse(method_exists($this->gateway, 'deleteCard'));
173+
}
174+
}
175+
176+
public function testSupportsUpdateCard()
177+
{
178+
$supportsUpdate = $this->gateway->supportsUpdateCard();
179+
$this->assertInternalType('boolean', $supportsUpdate);
180+
181+
if ($supportsUpdate) {
182+
$this->assertInstanceOf('Omnipay\Common\Message\RequestInterface', $this->gateway->updateCard());
183+
} else {
184+
$this->assertFalse(method_exists($this->gateway, 'updateCard'));
173185
}
174186
}
175187

@@ -290,9 +302,26 @@ public function testVoidParameters()
290302
}
291303
}
292304

293-
public function testCreateParameters()
305+
public function testCreateCardParameters()
306+
{
307+
if ($this->gateway->supportsCreateCard()) {
308+
foreach ($this->gateway->getDefaultParameters() as $key => $default) {
309+
// set property on gateway
310+
$getter = 'get'.ucfirst($key);
311+
$setter = 'set'.ucfirst($key);
312+
$value = uniqid();
313+
$this->gateway->$setter($value);
314+
315+
// request should have matching property, with correct value
316+
$request = $this->gateway->createCard();
317+
$this->assertSame($value, $request->$getter());
318+
}
319+
}
320+
}
321+
322+
public function testDeleteCardParameters()
294323
{
295-
if ($this->gateway->supportsCreate()) {
324+
if ($this->gateway->supportsDeleteCard()) {
296325
foreach ($this->gateway->getDefaultParameters() as $key => $default) {
297326
// set property on gateway
298327
$getter = 'get'.ucfirst($key);
@@ -301,15 +330,15 @@ public function testCreateParameters()
301330
$this->gateway->$setter($value);
302331

303332
// request should have matching property, with correct value
304-
$request = $this->gateway->create();
333+
$request = $this->gateway->deleteCard();
305334
$this->assertSame($value, $request->$getter());
306335
}
307336
}
308337
}
309338

310-
public function testDeleteParameters()
339+
public function testUpdateCardParameters()
311340
{
312-
if ($this->gateway->supportsDelete()) {
341+
if ($this->gateway->supportsUpdateCard()) {
313342
foreach ($this->gateway->getDefaultParameters() as $key => $default) {
314343
// set property on gateway
315344
$getter = 'get'.ucfirst($key);
@@ -318,7 +347,7 @@ public function testDeleteParameters()
318347
$this->gateway->$setter($value);
319348

320349
// request should have matching property, with correct value
321-
$request = $this->gateway->delete();
350+
$request = $this->gateway->updateCard();
322351
$this->assertSame($value, $request->$getter());
323352
}
324353
}

0 commit comments

Comments
 (0)