GatewayTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 56
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A testGateway() 0 6 1
A testCompletePurchase() 0 11 1
A testPurchase() 0 14 1
1
<?php
2
/**
3
 * ePayService driver for the Omnipay PHP payment processing library.
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-epayservice
6
 * @package   omnipay-epayservice
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\ePayService;
12
13
use Omnipay\Tests\GatewayTestCase;
14
15
class GatewayTest extends GatewayTestCase
16
{
17
    public $gateway;
18
19
    private $purse          = '[email protected]';
20
    private $secret         = 'sDf#$Sdf#$%';
21
    private $testMode       = true;
22
    private $transactionId  = 'sadf2345asf';
23
    private $description    = 'Test completePurchase description';
24
    private $currency       = 'USD';
25
    private $amount         = '12.46';
26
27
    public function setUp()
28
    {
29
        parent::setUp();
30
31
        $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest());
32
        $this->gateway->setPurse($this->purse);
33
        $this->gateway->setSecret($this->secret);
34
        $this->gateway->setTestMode($this->testMode);
35
    }
36
37
    public function testGateway()
38
    {
39
        $this->assertSame($this->purse,     $this->gateway->getPurse());
40
        $this->assertSame($this->secret,    $this->gateway->getSecret());
41
        $this->assertSame($this->testMode,  $this->gateway->getTestMode());
42
    }
43
44
    public function testCompletePurchase()
45
    {
46
        $request = $this->gateway->completePurchase([
47
            'transactionId' => $this->transactionId,
48
        ]);
49
50
        $this->assertSame($this->purse,         $request->getPurse());
51
        $this->assertSame($this->secret,        $request->getSecret());
52
        $this->assertSame($this->testMode,      $request->getTestMode());
53
        $this->assertSame($this->transactionId, $request->getTransactionId());
54
    }
55
56
    public function testPurchase()
57
    {
58
        $request = $this->gateway->purchase([
59
            'transactionId' => $this->transactionId,
60
            'description'   => $this->description,
61
            'currency'      => $this->currency,
62
            'amount'        => $this->amount,
63
        ]);
64
65
        $this->assertSame($this->transactionId, $request->getTransactionId());
66
        $this->assertSame($this->description,   $request->getDescription());
67
        $this->assertSame($this->currency,      $request->getCurrency());
68
        $this->assertSame($this->amount,        $request->getAmount());
69
    }
70
}
71