Completed
Pull Request — master (#13)
by Harry
02:22
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
19
class ClientTest extends TestCase
20
{
21
    public function testNewInstance()
22
    {
23
        $client = new Client();
24
        $this->assertTrue($client instanceof Client);
25
        $this->assertRegExp('/^DogStatsD\\\Client::\[[a-zA-Z0-9]+\]$/', (String) $client);
26
    }
27
28
    public function testStaticInstance()
29
    {
30
        $client1 = Client::instance('instance1');
31
        $this->assertTrue($client1 instanceof Client);
32
        $client2 = Client::instance('instance2');
33
        $client3 = Client::instance('instance1');
34
        $this->assertEquals('DogStatsD\Client::[instance2]', (String) $client2);
35
        $this->assertFalse((String) $client1 === (String) $client2);
36
        $this->assertTrue((String) $client1 === (String) $client3);
37
    }
38
39
    public function testDestruction()
40
    {
41
        $client = new Client();
42
        $client->configure([]);
43
        $client->increment('test', 1);
44
        $client = null;
45
46
        $this->assertNull($client);
47
    }
48
}
49