Completed
Push — master ( f9b271...616eb6 )
by Jacob
02:11
created

PhpQuickProfilerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A testConstruct() 0 10 1
A testGetReadableTime() 0 12 2
1
<?php
2
3
use Particletree\Pqp\Console;
4
use Particletree\Pqp\PhpQuickProfiler;
5
6
class PhpQuickProfilerTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
9
    public function __construct()
10
    {
11
    }
12
13
    public function testConstruct()
14
    {
15
        $console = new Console();
16
        $startTime = microtime(true);
17
18
        $profiler = new PhpQuickProfiler($console, $startTime);
19
20
        $this->assertAttributeSame($console, 'console', $profiler);
21
        $this->assertAttributeEquals($startTime, 'startTime', $profiler);
22
    }
23
24
    public function testGetReadableTime()
25
    {
26
        $test_input = array(
27
            '.032432' => '32.432 ms',
28
            '24.3781' => '24.378 s',
29
            '145.123' => '2.419 m'
30
        );
31
32
        foreach ($test_input as $input => $expected_return) {
33
            $this->assertEquals($expected_return, PhpQuickProfiler::getReadableTime($input));
34
        }
35
    }
36
}
37