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
|
|
|
} |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.