Completed
Push — master ( 52a46f...98e19a )
by Petrică
02:29
created

CpuAverageGagugeTest::testGetSamplingPeriod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Petrica
5
 * Date: 3/22/2016
6
 * Time: 23:26
7
 */
8
namespace Petrica\StatsdSystem\Tests\Gauge;
9
10
use Petrica\StatsdSystem\Gauge\CpuAverageGauge;
11
12
class CpuAverageGagugeTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * Test load average
16
     */
17
    public function testGetGauge()
18
    {
19
        $gauge = $this->getMockBuilder('Petrica\StatsdSystem\Gauge\CpuAverageGauge')
20
            ->setMethods(array(
21
                'getLoadAverage'
22
            ))
23
            ->getMock();
24
25
        $gauge->expects($this->exactly(2))
26
            ->method('getLoadAverage')
27
            ->willReturnOnConsecutiveCalls(
28
                false,
29
                array(0.5, 1, 1)
30
            );
31
32
        $collection = $gauge->getCollection();
33
        $values = $collection->getValues();
34
        // First value failed
35
        $this->assertEquals(array('load.average' => null), $values);
36
37
        $collection = $gauge->getCollection();
38
        $values = $collection->getValues();
39
        // Second call succeeded
40
        $this->assertEquals(array('load.average' => 0.5), $values);
41
    }
42
43
    public function testGetSamplingPeriod()
44
    {
45
        $gauge = new CpuAverageGauge();
46
47
        $this->assertEquals(60, $gauge->getSamplingPeriod());
48
    }
49
}
50