Passed
Push — master ( 170ab0...f3a34d )
by Dmitry
01:14
created

ClientTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 72.21%

Importance

Changes 0
Metric Value
wmc 5
eloc 16
dl 0
loc 50
ccs 13
cts 18
cp 0.7221
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidServiceNamesDataProvider() 0 4 1
A testCreatesService() 0 5 1
A setUp() 0 6 1
A testThrowsServiceNotFoundExceptionOnInvalidServiceName() 0 5 1
A validServiceNamesDataProvider() 0 6 1
1
<?php
2
3
namespace Pomopult\Dadata\Tests;
4
5
use Promopult\Dadata\Client;
6
use PHPUnit\Framework\TestCase;
7
8
class ClientTest extends TestCase
9
{
10
    private $client;
11
12 4
    public function setUp(): void
13
    {
14 4
        $this->client = new Client(
15 4
            'token',
16 4
            'secret',
17 4
            new \Http\Adapter\Guzzle6\Client()
18
        );
19 4
    }
20
21
    /**
22
     * @param string $name
23
     *
24
     * @dataProvider validServiceNamesDataProvider
25
     */
26 3
    public function testCreatesService($name)
27
    {
28 3
        $service = $this->client->getService($name);
29
30 3
        $this->assertInstanceOf(\Promopult\Dadata\Service::class, $service);
31 3
    }
32
33
    /**
34
     * @param string $name
35
     *
36
     * @dataProvider invalidServiceNamesDataProvider
37
     */
38 1
    public function testThrowsServiceNotFoundExceptionOnInvalidServiceName($name)
39
    {
40 1
        $this->expectException(\Promopult\Dadata\Exceptions\ServiceNotFoundException::class);
41
42 1
        $this->client->getService($name);
43
    }
44
45
    public function validServiceNamesDataProvider()
46
    {
47
        return [
48
            ['clean'],
49
            ['suggestions'],
50
            ['profile']
51
        ];
52
    }
53
54
    public function invalidServiceNamesDataProvider()
55
    {
56
        return [
57
            ['fuckyouservice'],
58
        ];
59
    }
60
}
61