ClientTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 5
rs 10
ccs 4
cts 4
cp 1
cc 1
nc 1
nop 0
crap 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