Completed
Push — master ( 1b7afa...9fbca5 )
by Dmitry
03:33
created

OldPurchaseResponseTest::setUp()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 20

Duplication

Lines 25
Ratio 100 %

Importance

Changes 4
Bugs 0 Features 3
Metric Value
c 4
b 0
f 3
dl 25
loc 25
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
1
<?php
2
3
/*
4
 * InterKassa driver for the Omnipay PHP payment processing library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-interkassa
7
 * @package   omnipay-interkassa
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\InterKassa\Tests\Message;
13
14
use Omnipay\InterKassa\Message\OldPurchaseRequest;
15
use Omnipay\InterKassa\Message\PurchaseResponse;
16
use Omnipay\InterKassa\Stubs\OldPurchaseResponseStub;
17
18
class OldPurchaseResponseTest extends PurchaseResponseTest
19
{
20
    /**
21
     * @var PurchaseResponse
22
     */
23
    protected $request;
24
25
    /**
26
     * @var OldPurchaseResponseStub
27
     */
28
    private $stub;
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...
29
30 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...
31
    {
32
        parent::setUp();
33
34
        $this->stub = new OldPurchaseResponseStub();
35
        $stub = $this->stub;
36
37
        $this->request = new OldPurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Omnipay\InterKassa\...this->getHttpRequest()) of type object<Omnipay\InterKass...age\OldPurchaseRequest> is incompatible with the declared type object<Omnipay\InterKass...ssage\PurchaseResponse> of property $request.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
        $this->request->initialize([
39
            'purse' => $stub->purse,
40
            'signAlgorithm' => $stub->signAlgorithm,
41
            'signKey' => $stub->signKey,
42
            'testKey' => $stub->testKey,
43
            'returnUrl' => $stub->returnUrl,
44
            'cancelUrl' => $stub->cancelUrl,
45
            'notifyUrl' => $stub->notifyUrl,
46
            'returnMethod' => $stub->returnMethod,
47
            'cancelMethod' => $stub->cancelMethod,
48
            'notifyMethod' => $stub->notifyMethod,
49
            'description' => $stub->description,
50
            'transactionId' => $stub->transactionId,
51
            'amount' => $stub->amount,
52
            'currency' => $stub->currency,
53
        ]);
54
    }
55
56
    public function testSuccess()
57
    {
58
        /** @var PurchaseResponse $response */
59
        $response = $this->request->send();
0 ignored issues
show
Bug introduced by
The method send() does not seem to exist on object<Omnipay\InterKass...ssage\PurchaseResponse>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
        $stub = $this->stub;
61
62
        $this->assertFalse($response->isSuccessful());
63
        $this->assertTrue($response->isRedirect());
64
        $this->assertNull($response->getCode());
65
        $this->assertNull($response->getMessage());
66
67
        $this->assertSame('POST', $response->getRedirectMethod());
68
        $this->assertSame([
69
            'ik_shop_id' => $stub->purse,
70
            'ik_payment_amount' => $stub->amount,
71
            'ik_payment_id' => $stub->transactionId,
72
            'ik_payment_desc' => $stub->description,
73
            'ik_success_url' => $stub->returnUrl,
74
            'ik_success_method' => $stub->returnMethod,
75
            'ik_fail_url' => $stub->cancelUrl,
76
            'ik_fail_method' => $stub->cancelMethod,
77
            'ik_status_url' => $stub->notifyUrl,
78
            'ik_status_method' => $stub->notifyMethod,
79
        ], $response->getRedirectData());
80
    }
81
}
82