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

ClientTest::testCreatesService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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