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

CompletePurchaseRequestTest::testSendData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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
use Symfony\Component\HttpFoundation\Request as HttpRequest;
16
17
class CompletePurchaseRequestTest extends TestCase
18
{
19
    private $request;
20
21
    private $purse                  = 'ec12345';
22
    private $secret                 = '22SAD#-78G8sdf$88';
23
    private $hash                   = '1d4d18e1eea386654e1af89e89f1a104'; // d41d8cd98f00b204e9800998ecf8427e 954f1176a05a5921118f49285beea2bb
24
    private $description            = 'Test Transaction long description';
25
    private $transactionId          = '1SD672345A890sd';
26
    private $transactionReference   = 'sdfa1SD672345A8';
27
    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...
28
    private $amount                 = '1465.01';
29
    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...
30
    private $testMode               = true;
31
32
    public function setUp()
33
    {
34
        parent::setUp();
35
36
        $httpRequest = new HttpRequest([], [
37
            'check_key'         => $this->hash,
38
            'EPS_DESCRIPTION'   => $this->description,
39
            'EPS_GUID'          => $this->purse,
40
            'EPS_AMOUNT'        => $this->amount,
41
            'EPS_TRID'          => $this->transactionId,
42
            'EPS_ACCNUM'        => $this->transactionReference,
43
            'EPS_GUID'          => $this->purse,
44
        ]);
45
46
        $this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest);
47
        $this->request->initialize([
48
            'purse'         => $this->purse,
49
            'secret'        => $this->secret,
50
            'testMode'      => $this->testMode,
51
        ]);
52
    }
53
54 View Code Duplication
    public function testGetData()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
    {
56
        $data = $this->request->getData();
57
58
        $this->assertSame($this->description,   $data['EPS_DESCRIPTION']);
59
        $this->assertSame($this->transactionId, $data['EPS_TRID']);
60
        $this->assertSame($this->hash,          $data['check_key']);
61
        $this->assertSame($this->amount,        $data['EPS_AMOUNT']);
62
        $this->assertSame($this->purse,         $data['EPS_GUID']);
63
    }
64
65
    public function testSendData()
66
    {
67
        $data = $this->request->getData();
68
        $response = $this->request->sendData($data);
69
        $this->assertInstanceOf('Omnipay\ePayService\Message\CompletePurchaseResponse', $response);
70
    }
71
}
72