Completed
Push — master ( 91f911...d54fb1 )
by Dmitry
01:20
created

CompletePurchaseResponseTest::testSuccess()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 28
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 24
nc 1
nop 0
1
<?php
2
/**
3
 * OKPAY driver for Omnipay PHP payment library.
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-okpay
6
 * @package   omnipay-okpay
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\OKPAY\Message;
12
13
use Omnipay\Tests\TestCase;
14
15
class CompletePurchaseResponseTest extends TestCase
16
{
17
    private $request;
18
19
    private $purse                  = '[email protected]';
20
    private $description            = 'sDf#$Sdf#$%';
21
    private $transactionId          = 1234567890;
22
    private $amount                 = '8.69';
23
    private $currency               = 'USD';
24
    private $testMode               = true;
25
    private $status                 = 'completed';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
26
    private $fee                    = '0.00';
27
    private $payer_first_name       = 'FirstName';
28
    private $payer_last_name        = 'LastName';
29
    private $payer_email            = '[email protected]';
30
    private $datetime               = '2017-09-20 16:07:50';
31
32
    public function setUp()
33
    {
34
        parent::setUp();
35
36
        $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
37
        $this->request->initialize([
38
            'purse'     => $this->purse,
39
            'secret'    => $this->secret,
0 ignored issues
show
Bug introduced by
The property secret does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
40
            'testMode'  => $this->testMode,
41
        ]);
42
    }
43
44
    public function testSuccess()
45
    {
46
        $response = new CompletePurchaseResponse($this->request, [
47
            'ok_item_1_name'            => $this->description,
48
            'ok_receiver'               => $this->purse,
49
            'ok_txn_gross'              => $this->amount,
50
            'ok_txn_datetime'           => $this->datetime,
51
            'ok_txn_id'                 => $this->transactionId,
52
            'ok_txn_status'             => $this->status,
53
            'ok_txn_currency'           => $this->currency,
54
            'ok_txn_fee'                => $this->fee,
55
            'ok_payer_first_name'       => $this->payer_first_name,
56
            'ok_payer_last_name'        => $this->payer_last_name,
57
            'ok_payer_email'            => $this->payer_email,
58
        ]);
59
60
        $this->assertTrue($response->isSuccessful());
61
        $this->assertNull($response->getMessage());
62
        $this->assertNull($response->getCode());
63
        $this->assertSame($this->amount,                $response->getAmount());
64
        $this->assertSame($this->description,           $response->getDescription());
65
        $this->assertSame($this->purse,                 $response->getPurse());
66
        $this->assertSame($this->currency,              $response->getCurrency());
67
        $this->assertSame($this->transactionId,         $response->getTransactionId());
68
        $this->assertSame($this->fee,                   $response->getFee());
69
        $this->assertEquals(new \DateTime($this->datetime), $response->getTime());
70
        $this->assertSame($this->payer_first_name . ' ' . $this->payer_last_name . ' / ' . $this->payer_email, $response->getPayer());
71
    }
72
}
73