Completed
Push — master ( 7b925c...58155c )
by Dmitry
10s
created

CompletePurchaseResponseTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 57
rs 10
c 2
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A testInvalidHashException() 0 10 1
A testSuccess() 0 18 1
1
<?php
2
3
/*
4
 * ePayService driver for Omnipay PHP payment library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-epayservice
7
 * @package   omnipay-epayservice
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\ePayService\Message;
13
14
use Omnipay\Tests\TestCase;
15
16
class CompletePurchaseResponseTest extends TestCase
17
{
18
    private $request;
19
20
    private $purse                  = 'ec12345';
21
    private $secret                 = '22SAD#-78G8sdf$88';
22
    private $hash                   = '1d4d18e1eea386654e1af89e89f1a104'; // d41d8cd98f00b204e9800998ecf8427e 954f1176a05a5921118f49285beea2bb
23
    private $description            = 'Test Transaction long description';
24
    private $transactionId          = '1SD672345A890sd';
25
    private $transactionReference   = 'sdfa1SD672345A8';
26
    private $timestamp              = '1454331086';
0 ignored issues
show
Unused Code introduced by
The property $timestamp is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
27
    private $amount                 = '1465.01';
28
    private $currency               = 'USD';
0 ignored issues
show
Unused Code introduced by
The property $currency is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
29
    private $testMode               = true;
30
31
    public function setUp()
32
    {
33
        parent::setUp();
34
35
        $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
36
        $this->request->initialize([
37
            'purse'     => $this->purse,
38
            'secret'    => $this->secret,
39
            'testMode'  => $this->testMode,
40
        ]);
41
    }
42
43
    public function testInvalidHashException()
44
    {
45
        $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Invalid hash');
46
        new CompletePurchaseResponse($this->request, [
47
            'description'           => $this->description,
48
            'purse'                 => $this->purse,
49
            'secret'                => $this->secret,
50
            'testMode'              => $this->testMode,
51
        ]);
52
    }
53
54
    public function testSuccess()
55
    {
56
        $response = new CompletePurchaseResponse($this->request, [
57
            'testMode'              => $this->testMode,
58
            'check_key'             => $this->hash,
59
            'EPS_DESCRIPTION'       => $this->description,
60
            'EPS_GUID'              => $this->purse,
61
            'EPS_AMOUNT'            => $this->amount,
62
            'EPS_TRID'              => $this->transactionId,
63
            'EPS_ACCNUM'            => $this->transactionReference,
64
        ]);
65
66
        $this->assertTrue($response->isSuccessful());
67
        $this->assertSame($this->transactionId,         $response->getTransactionId());
68
        $this->assertSame($this->transactionReference,  $response->getTransactionReference());
69
        $this->assertSame($this->amount,                $response->getAmount());
70
        $this->assertSame($this->hash,                  $response->getHash());
71
    }
72
}
73