|
@@ 37-53 (lines=17) @@
|
| 34 |
|
* with: twoCommands |
| 35 |
|
* should: returnTwo |
| 36 |
|
*/ |
| 37 |
|
public function test_callGetCommandCount_twoCommands_returnTwo() |
| 38 |
|
{ |
| 39 |
|
$natsLoggerMock = $this->getMockBuilder('Octante\NatsBundle\Logger\NatsLogger') |
| 40 |
|
->disableOriginalConstructor() |
| 41 |
|
->getMock(); |
| 42 |
|
|
| 43 |
|
$natsLoggerMock->expects($this->once()) |
| 44 |
|
->method('getCommands') |
| 45 |
|
->willReturn(array(1,2)); |
| 46 |
|
|
| 47 |
|
$requestMock = $this->getMock('Symfony\Component\HttpFoundation\Request'); |
| 48 |
|
$responseMock = $this->getMock('Symfony\Component\HttpFoundation\Response'); |
| 49 |
|
|
| 50 |
|
$sut = new NatsDataCollector($natsLoggerMock); |
| 51 |
|
$sut->collect($requestMock, $responseMock); |
| 52 |
|
$this->assertEquals(2, $sut->getCommandCount()); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
/** |
| 56 |
|
* when: callGetErrorCommandsCount |
|
@@ 60-80 (lines=21) @@
|
| 57 |
|
* with: aLoggerWithAnError |
| 58 |
|
* should: returnOne |
| 59 |
|
*/ |
| 60 |
|
public function test_callGetErrorCommandsCount_aLoggerWithAnError_returnOne() |
| 61 |
|
{ |
| 62 |
|
$natsLoggerMock = $this->getMockBuilder('Octante\NatsBundle\Logger\NatsLogger') |
| 63 |
|
->disableOriginalConstructor() |
| 64 |
|
->getMock(); |
| 65 |
|
|
| 66 |
|
$natsLoggerMock->expects($this->once()) |
| 67 |
|
->method('getCommands') |
| 68 |
|
->willReturn( |
| 69 |
|
array( |
| 70 |
|
'commands' => array('error' => null) |
| 71 |
|
) |
| 72 |
|
); |
| 73 |
|
|
| 74 |
|
$requestMock = $this->getMock('Symfony\Component\HttpFoundation\Request'); |
| 75 |
|
$responseMock = $this->getMock('Symfony\Component\HttpFoundation\Response'); |
| 76 |
|
|
| 77 |
|
$sut = new NatsDataCollector($natsLoggerMock); |
| 78 |
|
$sut->collect($requestMock, $responseMock); |
| 79 |
|
$this->assertEquals(1, $sut->getErrorCommandsCount()); |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
/** |
| 83 |
|
* when: getTimeIsCalled |
|
@@ 87-107 (lines=21) @@
|
| 84 |
|
* with: oneCommandInLogger |
| 85 |
|
* should: returnTime |
| 86 |
|
*/ |
| 87 |
|
public function test_getTimeIsCalled_oneCommandInLogger_returnTime() |
| 88 |
|
{ |
| 89 |
|
$natsLoggerMock = $this->getMockBuilder('Octante\NatsBundle\Logger\NatsLogger') |
| 90 |
|
->disableOriginalConstructor() |
| 91 |
|
->getMock(); |
| 92 |
|
|
| 93 |
|
$natsLoggerMock->expects($this->once()) |
| 94 |
|
->method('getCommands') |
| 95 |
|
->willReturn( |
| 96 |
|
array( |
| 97 |
|
'commands' => array('executionMS' => 1000) |
| 98 |
|
) |
| 99 |
|
); |
| 100 |
|
|
| 101 |
|
$requestMock = $this->getMock('Symfony\Component\HttpFoundation\Request'); |
| 102 |
|
$responseMock = $this->getMock('Symfony\Component\HttpFoundation\Response'); |
| 103 |
|
|
| 104 |
|
$sut = new NatsDataCollector($natsLoggerMock); |
| 105 |
|
$sut->collect($requestMock, $responseMock); |
| 106 |
|
$this->assertEquals(1000, $sut->getTime()); |
| 107 |
|
} |
| 108 |
|
} |
| 109 |
|
|