Issues (7)

tests/unit/TimerTest.php (1 issue)

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\Test\TestCase;
17
18
class TimerTest extends TestCase
19
{
20
    public function testTiming()
21
    {
22
        $this->client->timing('test_metric', 123);
23
        $this->assertEquals('test_metric:123|ms', $this->client->getLastMessage());
24
    }
25
26
    public function testFunctionTiming()
27
    {
28
        $this->client->time('test_metric', function () {
29
            usleep(100000);
30
        });
31
        $this->assertRegExp('/test_metric:1[0-9]{2}\.[0-9]+\|ms/', $this->client->getLastMessage());
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertRegExp() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/4086 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

31
        /** @scrutinizer ignore-deprecated */ $this->assertRegExp('/test_metric:1[0-9]{2}\.[0-9]+\|ms/', $this->client->getLastMessage());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
32
    }
33
34
    public function testTags()
35
    {
36
        $this->client->timing('test_metric', 123, ['tag']);
37
        $this->assertEquals('test_metric:123|ms|#tag', $this->client->getLastMessage());
38
    }
39
}
40