PurchaseRequestTest::testGetData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Message;
12
13
use Omnipay\Tests\TestCase;
14
15
class PurchaseRequestTest extends TestCase
16
{
17
    private $request;
18
19
    private $purse          = '[email protected]';
20
    private $secret         = '22SAD#-78G888';
21
    private $returnUrl      = 'https://www.foodstore.com/success';
22
    private $cancelUrl      = 'https://www.foodstore.com/failure';
23
    private $notifyUrl      = 'https://www.foodstore.com/notify';
24
    private $description    = 'Test Transaction long description';
25
    private $transactionId  = '12345ASD67890sd';
26
    private $amount         = '14.65';
27
    private $quantity       = '1';
28
    private $currency       = 'USD';
29
    private $testMode       = true;
30
31 View Code Duplication
    public function setUp()
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...
32
    {
33
        parent::setUp();
34
35
        $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
36
        $this->request->initialize([
37
            'purse'         => $this->purse,
38
            'secret'        => $this->secret,
39
            'returnUrl'     => $this->returnUrl,
40
            'cancelUrl'     => $this->cancelUrl,
41
            'notifyUrl'     => $this->notifyUrl,
42
            'description'   => $this->description,
43
            'amount'        => $this->amount,
44
            'currency'      => $this->currency,
45
            'testMode'      => $this->testMode,
46
        ]);
47
    }
48
49 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...
50
    {
51
        $data = $this->request->getData();
52
53
        $this->assertSame($this->purse,         $data['EPS_GUID']);
54
        $this->assertSame($this->returnUrl,     $data['EPS_SUCCESS_URL']);
55
        $this->assertSame($this->cancelUrl,     $data['EPS_FAIL_URL']);
56
        $this->assertSame($this->notifyUrl,     $data['EPS_RESULT_URL']);
57
        $this->assertSame($this->description,   $data['EPS_DESCRIPTION']);
58
        $this->assertSame($this->amount,        $data['EPS_AMOUNT']);
59
    }
60
61
    public function testSendData()
62
    {
63
        $data = $this->request->getData();
64
        $response = $this->request->sendData($data);
65
        $this->assertInstanceOf(\Omnipay\ePayService\Message\PurchaseResponse::class, $response);
66
    }
67
}
68