Skip to content

Commit 4e49d8c

Browse files
committed
Created some test coverage for DPM.
1 parent cf12bd6 commit 4e49d8c

File tree

5 files changed

+107
-3
lines changed

5 files changed

+107
-3
lines changed

src/AIMGateway.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function getDefaultParameters()
2222
'testMode' => false,
2323
'developerMode' => false,
2424
'liveEndpoint' => 'https://secure.authorize.net/gateway/transact.dll',
25-
'developerEndpoint' => 'https://test.authorize.net/gateway/transact.dll'
25+
'developerEndpoint' => 'https://test.authorize.net/gateway/transact.dll',
2626
);
2727
}
2828

src/Message/DPMResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getRedirectUrl()
109109

110110
public function getRedirectMethod()
111111
{
112-
return "post";
112+
return 'POST';
113113
}
114114

115115
/**
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
namespace Omnipay\AuthorizeNet\Message;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class DPMAuthorizeRequestTest extends TestCase
8+
{
9+
public function setUp()
10+
{
11+
$this->request = new DPMAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
12+
$this->request->initialize(
13+
array(
14+
'clientIp' => '10.0.0.1',
15+
'amount' => '12.00',
16+
'returnUrl' => 'https://www.example.com/return',
17+
'liveEndpoint' => 'https://secure.authorize.net/gateway/transact.dll',
18+
'developerEndpoint' => 'https://test.authorize.net/gateway/transact.dll',
19+
)
20+
);
21+
}
22+
23+
public function testGetData()
24+
{
25+
$data = $this->request->getData();
26+
27+
$this->assertSame('AUTH_ONLY', $data['x_type']);
28+
$this->assertArrayNotHasKey('x_show_form', $data);
29+
$this->assertArrayNotHasKey('x_test_request', $data);
30+
}
31+
32+
public function testGetDataTestMode()
33+
{
34+
$this->request->setTestMode(true);
35+
36+
$data = $this->request->getData();
37+
38+
$this->assertSame('TRUE', $data['x_test_request']);
39+
}
40+
41+
public function testGetHash()
42+
{
43+
$this->request->setApiLoginId('user');
44+
$this->request->setTransactionKey('key');
45+
$data = array(
46+
'x_fp_sequence' => 'a',
47+
'x_fp_timestamp' => 'b',
48+
'x_amount' => 'c',
49+
);
50+
51+
$expected = hash_hmac('md5', 'user^a^b^c^', 'key');
52+
53+
$this->assertSame($expected, $this->request->getHash($data));
54+
}
55+
56+
public function testSend()
57+
{
58+
$response = $this->request->send();
59+
60+
$this->assertFalse($response->isSuccessful());
61+
$this->assertTrue($response->isRedirect());
62+
$this->assertNotEmpty($response->getRedirectUrl());
63+
$this->assertSame('POST', $response->getRedirectMethod());
64+
65+
$redirectData = $response->getRedirectData();
66+
$this->assertSame('https://www.example.com/return', $redirectData['x_relay_url']);
67+
}
68+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Omnipay\AuthorizeNet\Message;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class DPMPurchaseRequestTest extends TestCase
8+
{
9+
public function setUp()
10+
{
11+
$this->request = new DPMPurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
12+
$this->request->initialize(
13+
array(
14+
'clientIp' => '10.0.0.1',
15+
'amount' => '12.00',
16+
'customerId' => 'cust-id',
17+
'card' => $this->getValidCard(),
18+
'returnUrl' => 'https://www.example.com/return',
19+
'liveEndpoint' => 'https://secure.authorize.net/gateway/transact.dll',
20+
'developerEndpoint' => 'https://test.authorize.net/gateway/transact.dll',
21+
)
22+
);
23+
}
24+
25+
public function testGetData()
26+
{
27+
$data = $this->request->getData();
28+
29+
$this->assertSame('AUTH_CAPTURE', $data['x_type']);
30+
$this->assertSame('10.0.0.1', $data['x_customer_ip']);
31+
$this->assertSame('cust-id', $data['x_cust_id']);
32+
$this->assertArrayNotHasKey('x_test_request', $data);
33+
}
34+
}

tests/Message/SIMAuthorizeRequestTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public function setUp()
1414
'clientIp' => '10.0.0.1',
1515
'amount' => '12.00',
1616
'returnUrl' => 'https://www.example.com/return',
17+
'liveEndpoint' => 'https://secure.authorize.net/gateway/transact.dll',
18+
'developerEndpoint' => 'https://test.authorize.net/gateway/transact.dll',
1719
)
1820
);
1921
}
@@ -57,7 +59,7 @@ public function testSend()
5759

5860
$this->assertFalse($response->isSuccessful());
5961
$this->assertTrue($response->isRedirect());
60-
$this->assertNotEmpty($response->getRedirectUrl()); // This test is failing; not sure why.
62+
$this->assertNotEmpty($response->getRedirectUrl());
6163
$this->assertSame('POST', $response->getRedirectMethod());
6264

6365
$redirectData = $response->getRedirectData();

0 commit comments

Comments
 (0)