PaymentResourceTest::itReturnsAListOfPayments()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 15

Duplication

Lines 34
Ratio 100 %

Importance

Changes 0
Metric Value
dl 34
loc 34
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Bunq\Tests\Resource;
4
5
use Bunq\BunqClient;
6
use Bunq\Resource\PaymentResource;
7
use PHPUnit\Framework\TestCase;
8
9
final class PaymentResourceTest extends TestCase
10
{
11
    /**
12
     * @var BunqClient
13
     */
14
    private $bunqClient;
15
16
    /**
17
     * @var PaymentResource
18
     */
19
    private $resource;
20
21
    public function setUp()
22
    {
23
        $this->bunqClient = $this->prophesize(BunqClient::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->prophesize(\Bunq\BunqClient::class) of type object<Prophecy\Prophecy\ObjectProphecy> is incompatible with the declared type object<Bunq\BunqClient> of property $bunqClient.

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...
24
        $this->resource   = new PaymentResource($this->bunqClient->reveal());
25
    }
26
27
    /**
28
     * @test
29
     */
30 View Code Duplication
    public function itReturnsAListOfPayments()
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
        $this->bunqClient->get('/v1/user/1/monetary-account/1/payment')->willReturn(
0 ignored issues
show
Bug introduced by
The method willReturn cannot be called on $this->bunqClient->get('...ary-account/1/payment') (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
33
            [
34
                'Response' => [
35
                    [
36
                        'Payment' => [
37
                            'amount' => [
38
                                'value'    => '12.50',
39
                                'currency' => 'EUR',
40
                            ],
41
                        ],
42
                    ],
43
                ],
44
            ]
45
        );
46
47
        $result = $this->resource->listPayments(1, 1);
48
49
        $expectedResult = [
50
            'Response' => [
51
                [
52
                    'Payment' => [
53
                        'amount' => [
54
                            'value'    => 1250,
55
                            'currency' => 'EUR',
56
                        ],
57
                    ],
58
                ],
59
            ],
60
        ];
61
62
        $this->assertEquals($expectedResult, $result);
63
    }
64
65
    /**
66
     * @test
67
     */
68
    public function itReturnsASinglePayment()
69
    {
70
        $this->bunqClient->get('/v1/user/1/monetary-account/1/payment/1')->willReturn(
0 ignored issues
show
Bug introduced by
The method willReturn cannot be called on $this->bunqClient->get('...y-account/1/payment/1') (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
71
            [
72
                'Response' => [
73
                    [
74
                        'Payment' => [
75
                            'amount' => [
76
                                'value'    => '12.50',
77
                                'currency' => 'EUR',
78
                            ],
79
                        ],
80
81
                    ],
82
                ],
83
            ]
84
        );
85
86
        $result = $this->resource->getPayment(1, 1, 1);
87
88
        $expectedResult = [
89
            'amount' => [
90
                'value'    => '1250',
91
                'currency' => 'EUR',
92
            ],
93
        ];
94
95
        $this->assertEquals($expectedResult, $result);
96
    }
97
}
98