Code Duplication    Length = 8-16 lines in 8 locations

tests/unit/NamespaceTest.php 2 locations

@@ 20-29 (lines=10) @@
17
        $this->assertEquals('test_namespace', $this->client->getNamespace());
18
    }
19
20
    public function testNamespaceIncrement()
21
    {
22
        $this->client->configure(array(
23
            'host' => '127.0.0.1',
24
            'port' => 8125,
25
            'namespace' => 'test_namespace'
26
        ));
27
        $this->client->increment('test_metric');
28
        $this->assertEquals('test_namespace.test_metric:1|c', $this->client->getLastMessage());
29
    }
30
31
    public function testNamespaceEvent()
32
    {
@@ 42-51 (lines=10) @@
39
        $this->assertEquals('_e{10,13}:test_namespace.some_title|textAndThings', $this->client->getLastMessage());
40
    }
41
42
    public function testNamespaceSimpleService()
43
    {
44
        $this->client->configure(array(
45
            'host' => '127.0.0.1',
46
            'port' => 8125,
47
            'namespace' => 'test_namespace'
48
        ));
49
        $this->client->serviceCheck('service.api', Client::STATUS_OK);
50
        $this->assertEquals('_sc|test_namespace.service.api|0', $this->client->getLastMessage());
51
    }
52
}
53

tests/unit/ServiceCheckTest.php 4 locations

@@ 16-30 (lines=15) @@
13
        $this->assertEquals('_sc|service.api|0', $this->client->getLastMessage());
14
    }
15
16
    public function testMetaData()
17
    {
18
        $this->client->serviceCheck(
19
            'service.api',
20
            Client::STATUS_CRITICAL,
21
            [
22
                'time'     => 12345678,
23
                'hostname' => 'some.host',
24
            ]
25
        );
26
        $this->assertEquals(
27
            '_sc|service.api|2|d:12345678|h:some.host',
28
            $this->client->getLastMessage()
29
        );
30
    }
31
32
    public function testTags()
33
    {
@@ 32-47 (lines=16) @@
29
        );
30
    }
31
32
    public function testTags()
33
    {
34
        $this->client->serviceCheck(
35
            'service.api',
36
            Client::STATUS_WARNING,
37
            [
38
                'time'     => 12345678,
39
                'hostname' => 'some.host',
40
            ],
41
            ['tag']
42
        );
43
        $this->assertEquals(
44
            '_sc|service.api|1|d:12345678|h:some.host|#tag',
45
            $this->client->getLastMessage()
46
        );
47
    }
48
49
    public function testMessageIsAfterTags()
50
    {
@@ 49-64 (lines=16) @@
46
        );
47
    }
48
49
    public function testMessageIsAfterTags()
50
    {
51
        $this->client->serviceCheck(
52
            'service.api',
53
            Client::STATUS_UNKNOWN,
54
            [
55
                'time'    => 12345678,
56
                'message' => 'some_message',
57
            ],
58
            ['tag']
59
        );
60
        $this->assertEquals(
61
            '_sc|service.api|3|d:12345678|#tag|m:some_message',
62
            $this->client->getLastMessage()
63
        );
64
    }
65
66
    public function testCoreStatsDImplementation()
67
    {
@@ 66-75 (lines=10) @@
63
        );
64
    }
65
66
    public function testCoreStatsDImplementation()
67
    {
68
        $this->client->configure(array(
69
            'host' => '127.0.0.1',
70
            'port' => 8125,
71
            'dataDog' => false
72
        ));
73
        $this->client->serviceCheck('service.api', Client::STATUS_OK);
74
        $this->assertEquals('', $this->client->getLastMessage());
75
    }
76
}
77

tests/unit/TagsTest.php 2 locations

@@ 27-34 (lines=8) @@
24
        $this->assertEquals('test_metric:1|c|#tag:value,tag2,tag3:value2', $this->client->getLastMessage());
25
    }
26
27
    public function testCoreStatsDImplementation()
28
    {
29
        $this->client->configure([
30
            'dataDog' => false,
31
        ]);
32
        $this->client->increment('test_metric', 1, 1, ['tag']);
33
        $this->assertEquals('test_metric:1|c', $this->client->getLastMessage());
34
    }
35
36
    public function testDefaultTagsGetAddedToRequest()
37
    {
@@ 36-43 (lines=8) @@
33
        $this->assertEquals('test_metric:1|c', $this->client->getLastMessage());
34
    }
35
36
    public function testDefaultTagsGetAddedToRequest()
37
    {
38
        $this->client->configure([
39
            'tags' => ['tag1'],
40
        ]);
41
        $this->client->increment('test_metric', 1, 1, ['tag2']);
42
        $this->assertEquals('test_metric:1|c|#tag1,tag2', $this->client->getLastMessage());
43
    }
44
}
45