Test Setup Failed
Push — next ( 738e04...b06172 )
by Jonathan
25:05
created

MicrotimeRepresentationTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testConstruct() 0 24 1
A testGetDateTime() 0 10 1
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);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

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.

Loading history...
16
17
        $mem = memory_get_usage();
18
        $mem_peak = memory_get_peak_usage();
0 ignored issues
show
Coding Style introduced by
$mem_peak does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
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);
0 ignored issues
show
Coding Style introduced by
$mem_peak does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
36
    }
37
38
    /**
39
     * @covers \Kint\Object\Representation\MicrotimeRepresentation::getDateTime
40
     */
41
    public function testGetDateTime()
42
    {
43
        $r = new MicrotimeRepresentation(1234, 5678, 0);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

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.

Loading history...
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