| Conditions | 1 |
| Paths | 1 |
| Total Lines | 45 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function testGetGauge() |
||
| 13 | { |
||
| 14 | $gauge = $this->getMockBuilder('Petrica\StatsdSystem\Gauge\MemoryGauge') |
||
| 15 | ->setMethods(array( |
||
| 16 | 'getSystemMemoryInfo' |
||
| 17 | )) |
||
| 18 | ->getMock(); |
||
| 19 | |||
| 20 | $gauge->expects($this->exactly(4)) |
||
| 21 | ->method('getSystemMemoryInfo') |
||
| 22 | ->willReturnOnConsecutiveCalls( |
||
| 23 | array(), |
||
| 24 | array('MemTotal' => 5), |
||
| 25 | array('MemFree' => 15), |
||
| 26 | array('MemTotal' => 20, 'MemFree' => 5) |
||
| 27 | ); |
||
| 28 | |||
| 29 | # 1st call |
||
| 30 | $collection = $gauge->getCollection(); |
||
| 31 | $values = $collection->getValues(); |
||
| 32 | |||
| 33 | $this->assertEquals(array(), $values); |
||
| 34 | |||
| 35 | # 2nd call |
||
| 36 | $collection = $gauge->getCollection(); |
||
| 37 | $values = $collection->getValues(); |
||
| 38 | |||
| 39 | $this->assertEquals(array(), $values); |
||
| 40 | |||
| 41 | # 3rd call |
||
| 42 | $collection = $gauge->getCollection(); |
||
| 43 | $values = $collection->getValues(); |
||
| 44 | |||
| 45 | $this->assertEquals(array(), $values); |
||
| 46 | |||
| 47 | # 4th call |
||
| 48 | $collection = $gauge->getCollection(); |
||
| 49 | $values = $collection->getValues(); |
||
| 50 | |||
| 51 | $this->assertEquals(array( |
||
| 52 | 'total.value' => 20, |
||
| 53 | 'used.value' => 15, |
||
| 54 | 'free.value' => 5 |
||
| 55 | ), $values); |
||
| 56 | } |
||
| 57 | } |