Completed
Pull Request — master (#13)
by Harry
02:43
created

ClientTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 2
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testNewInstance() 0 6 1
A testStaticInstance() 0 10 1
A testDestruction() 0 9 1
1
<?php
2
/**
3
 * This file is part of graze/dog-statsd
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/dog-statsd/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/dog-statsd
12
 */
13
14
namespace Graze\DogStatsD\Test\Unit;
15
16
use Graze\DogStatsD\Client;
17
use Graze\DogStatsD\Test\TestCase;
18
use ReflectionProperty;
19
20
class ClientTest extends TestCase
21
{
22
    public function testNewInstance()
23
    {
24
        $client = new Client();
25
        $this->assertTrue($client instanceof Client);
26
        $this->assertRegExp('/^DogStatsD\\\Client::\[[a-zA-Z0-9]+\]$/', (String) $client);
27
    }
28
29
    public function testStaticInstance()
30
    {
31
        $client1 = Client::instance('instance1');
32
        $this->assertTrue($client1 instanceof Client);
33
        $client2 = Client::instance('instance2');
34
        $client3 = Client::instance('instance1');
35
        $this->assertEquals('DogStatsD\Client::[instance2]', (String) $client2);
36
        $this->assertFalse((String) $client1 === (String) $client2);
37
        $this->assertTrue((String) $client1 === (String) $client3);
38
    }
39
40
    public function testDestruction()
41
    {
42
        $client = new Client();
43
        $client->configure([]);
44
        $client->increment('test', 1);
45
        $client = null;
46
47
        $this->assertNull($client);
48
    }
49
}
50