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