ClientTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
eloc 15
c 3
b 0
f 0
dl 0
loc 49
rs 10
ccs 13
cts 17
cp 0.7647

5 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidServiceNamesDataProvider() 0 4 1
A testCreatesService() 0 5 1
A setUp() 0 5 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
            new \Promopult\Dadata\Credentials('token', 'secret'),
16 4
            new \GuzzleHttp\Client()
17 4
        );
18
    }
19 4
20
    /**
21
     * @param string $name
22
     *
23
     * @dataProvider validServiceNamesDataProvider
24
     */
25
    public function testCreatesService($name)
26 3
    {
27
        $service = $this->client->getService($name);
28 3
29
        $this->assertInstanceOf(\Promopult\Dadata\Service::class, $service);
30 3
    }
31 3
32
    /**
33
     * @param string $name
34
     *
35
     * @dataProvider invalidServiceNamesDataProvider
36
     */
37
    public function testThrowsServiceNotFoundExceptionOnInvalidServiceName($name)
38 1
    {
39
        $this->expectException(\Promopult\Dadata\Exceptions\ServiceNotFoundException::class);
40 1
41
        $this->client->getService($name);
42 1
    }
43
44
    public function validServiceNamesDataProvider()
45
    {
46
        return [
47
            ['clean'],
48
            ['suggestions'],
49
            ['profile']
50
        ];
51
    }
52
53
    public function invalidServiceNamesDataProvider()
54
    {
55
        return [
56
            ['fuckyouservice'],
57
        ];
58
    }
59
}
60