1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kint\Test\Object\Representation; |
4
|
|
|
|
5
|
|
|
use Kint\Object\Representation\MicrotimeRepresentation; |
6
|
|
|
use Kint\Test\KintTestCase; |
7
|
|
|
|
8
|
|
|
class MicrotimeRepresentationTest extends KintTestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @covers \Kint\Object\Representation\MicrotimeRepresentation::__construct |
12
|
|
|
*/ |
13
|
|
|
public function testConstruct() |
14
|
|
|
{ |
15
|
|
|
$r = new MicrotimeRepresentation(123, 456, 7, 8, 100); |
|
|
|
|
16
|
|
|
|
17
|
|
|
$mem = memory_get_usage(); |
18
|
|
|
$mem_peak = memory_get_peak_usage(); |
|
|
|
|
19
|
|
|
|
20
|
|
|
$this->assertSame(123, $r->seconds); |
21
|
|
|
$this->assertSame(456, $r->microseconds); |
22
|
|
|
$this->assertSame(7, $r->group); |
23
|
|
|
$this->assertSame(8, $r->lap); |
24
|
|
|
$this->assertSame(100, $r->total); |
25
|
|
|
$this->assertSame(0, $r->i); |
26
|
|
|
$this->assertNull($r->avg); |
27
|
|
|
|
28
|
|
|
$r = new MicrotimeRepresentation(123, 456, 7, 8, 100, 5); |
29
|
|
|
$this->assertSame(5, $r->i); |
30
|
|
|
$this->assertSame(20, $r->avg); |
31
|
|
|
|
32
|
|
|
// PHP 5.3 needs a leeway of 3k, 5.4+ needs 2k. |
33
|
|
|
// At some point in the 7.x range they become exactly equal. |
34
|
|
|
$this->assertLessThan(3000, abs($mem - $r->mem)); |
35
|
|
|
$this->assertSame($mem_peak, $r->mem_peak); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @covers \Kint\Object\Representation\MicrotimeRepresentation::getDateTime |
40
|
|
|
*/ |
41
|
|
|
public function testGetDateTime() |
42
|
|
|
{ |
43
|
|
|
$r = new MicrotimeRepresentation(1234, 5678, 0); |
|
|
|
|
44
|
|
|
$dt2 = $r->getDateTime(); |
45
|
|
|
$this->assertSame('1234.005678', $dt2->format('U.u')); |
46
|
|
|
|
47
|
|
|
$r = new MicrotimeRepresentation(1234, 0, 0); |
48
|
|
|
$dt2 = $r->getDateTime(); |
49
|
|
|
$this->assertSame('1234.000000', $dt2->format('U.u')); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.