CustomClientTraitUnitTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 12
c 1
b 0
f 1
dl 0
loc 45
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSendRequest() 0 18 1
A sendRequestDataProvider() 0 8 1
1
<?php
2
namespace Mezon\CustomClient\Tests;
3
4
/**
5
 *
6
 * @psalm-suppress PropertyNotSetInConstructor
7
 */
8
class CustomClientTraitUnitTest extends BaseTestUtilities
9
{
10
11
    /**
12
     * Data provider for sending requests tests
13
     *
14
     * @return array test data
15
     */
16
    public function sendRequestDataProvider(): array
17
    {
18
        return [
19
            [
20
                'sendPutRequest'
21
            ],
22
            [
23
                'sendDeleteRequest'
24
            ]
25
        ];
26
    }
27
28
    /**
29
     * Testing sendGetRequest method
30
     *
31
     * @param string $methodName
32
     *            Method name to be tested
33
     * @dataProvider sendRequestDataProvider
34
     */
35
    public function testSendRequest(string $methodName): void
36
    {
37
        // setup
38
        $client = $this->getMock([
39
            'sendPostRequest'
40
        ]);
41
        $client->method('sendPostRequest')->willReturn([
42
            'return',
43
            1
44
        ]);
45
        $client->setPutTraitMethod(true);
46
        $client->setDeleteTraitMethod(true);
47
48
        // test body
49
        $result = $client->$methodName('/end-point/');
50
51
        // assertions
52
        $this->assertEquals('return', $result[0]);
53
    }
54
}
55