1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spiral\Tests\Snapshotter; |
4
|
|
|
|
5
|
|
|
use Mockery\MockInterface; |
6
|
|
|
use Spiral\Debug\LogManager; |
7
|
|
|
use Spiral\Snapshotter\DelegateSnapshot; |
8
|
|
|
use Spiral\Snapshotter\HandlerInterface; |
9
|
|
|
use Spiral\Tests\BaseTest; |
10
|
|
|
use Symfony\Component\Debug\Debug; |
11
|
|
|
|
12
|
|
|
class DelegateTest extends BaseTest |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Test delegation contains snapshot render data. |
16
|
|
|
*/ |
17
|
|
|
public function testSnapshotRenderByPass() |
18
|
|
|
{ |
19
|
|
|
/** @var HandlerInterface $handler */ |
20
|
|
|
$handler = \Mockery::mock(HandlerInterface::class); |
21
|
|
|
|
22
|
|
|
$delegate = new DelegateSnapshot( |
23
|
|
|
new \Error('custom error'), |
|
|
|
|
24
|
|
|
$this->logs->getLogger(LogManager::DEBUG_CHANNEL), |
25
|
|
|
$this->container, |
26
|
|
|
$handler |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
$this->assertContains('custom error', $delegate->render()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Test snapshot error was logged. |
34
|
|
|
*/ |
35
|
|
|
public function testSnapshotReport() |
36
|
|
|
{ |
37
|
|
|
/** @var HandlerInterface|MockInterface $handler */ |
38
|
|
|
$handler = \Mockery::mock(HandlerInterface::class); |
39
|
|
|
$handler->shouldReceive('registerSnapshot'); |
|
|
|
|
40
|
|
|
|
41
|
|
|
$delegate = new DelegateSnapshot( |
42
|
|
|
new \Error('custom error'), |
|
|
|
|
43
|
|
|
$this->logs->getLogger(LogManager::DEBUG_CHANNEL), |
44
|
|
|
$this->container, |
45
|
|
|
$handler |
|
|
|
|
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
$this->assertEmpty($this->files->getFiles(directory('runtime') . 'logs/')); |
49
|
|
|
$delegate->report(); |
50
|
|
|
$this->assertNotEmpty($this->files->getFiles(directory('runtime') . 'logs/')); |
51
|
|
|
} |
52
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: