| Conditions | 1 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function testTransactionLog() |
||
| 15 | { |
||
| 16 | $request = new Request(); |
||
| 17 | $response = new Response(); |
||
| 18 | |||
| 19 | /** @var HttpTransactionRepository|\PHPUnit_Framework_MockObject_MockObject $httpTransactionRepository */ |
||
| 20 | $httpTransactionRepository = $this->getMockBuilder(HttpTransactionRepository::class) |
||
| 21 | ->disableOriginalConstructor() |
||
| 22 | ->getMock() |
||
| 23 | ; |
||
| 24 | |||
| 25 | $transactionCounter = 0; |
||
| 26 | |||
| 27 | $httpTransactionRepository |
||
|
|
|||
| 28 | ->expects($this->any()) |
||
| 29 | ->method('save') |
||
| 30 | ->willReturnCallback(function () use (&$transactionCounter) { |
||
| 31 | ++$transactionCounter; |
||
| 32 | }) |
||
| 33 | ; |
||
| 34 | |||
| 35 | $transactionLogger = new TransactionLogger($httpTransactionRepository); |
||
| 36 | $transactionLogger->setRequest($request); |
||
| 37 | $transactionLogger->setResponse($request, $response); |
||
| 38 | $transactionLogger->flush(); |
||
| 39 | |||
| 40 | $this->assertSame(1, $transactionCounter); |
||
| 41 | } |
||
| 42 | |||
| 51 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: