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

ClientTest::testDestruction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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