1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Bldr.io |
4
|
|
|
* |
5
|
|
|
* (c) Aaron Scherer <[email protected]> |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the MIT license that is bundled |
8
|
|
|
* with this source code in the file LICENSE |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Bldr\Test\Event; |
12
|
|
|
|
13
|
|
|
use Bldr\Event\PreExecuteEvent; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @author Mauricio Walters <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class PreExecuteEventTest extends \PHPUnit_Framework_TestCase |
19
|
|
|
{ |
20
|
|
|
public static function createPreExecuteEvent() |
21
|
|
|
{ |
22
|
|
|
$task = \Mockery::mock('Bldr\Task\TaskInterface'); |
23
|
|
|
$process = \Mockery::mock('Symfony\Component\Process\Process'); |
24
|
|
|
$process->shouldReceive('stop'); |
25
|
|
|
|
26
|
|
|
return new PreExecuteEvent($task, $process, false); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Tests the __construct($task, $builder) method |
31
|
|
|
* |
32
|
|
|
* @throws \PHPUnit_Framework_Exception |
33
|
|
|
* @return PreExecuteEvent |
34
|
|
|
*/ |
35
|
|
|
public function testFactory() |
36
|
|
|
{ |
37
|
|
|
$postExecuteEvent = self::createPreExecuteEvent(); |
38
|
|
|
|
39
|
|
|
$this->assertInstanceOf( |
40
|
|
|
'Bldr\Event\PreExecuteEvent', |
41
|
|
|
$postExecuteEvent |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
$this->assertInstanceOf( |
45
|
|
|
'Bldr\Event\AbstractEvent', |
46
|
|
|
$postExecuteEvent |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
return $postExecuteEvent; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testGetTask() |
53
|
|
|
{ |
54
|
|
|
$postExecuteEvent = self::createPreExecuteEvent(); |
55
|
|
|
|
56
|
|
|
$this->assertInstanceOf( |
57
|
|
|
'Bldr\Task\TaskInterface', |
58
|
|
|
$postExecuteEvent->getTask() |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testGetProcess() |
63
|
|
|
{ |
64
|
|
|
$postExecuteEvent = self::createPreExecuteEvent(); |
65
|
|
|
|
66
|
|
|
$this->assertInstanceOf( |
67
|
|
|
'Symfony\Component\Process\Process', |
68
|
|
|
$postExecuteEvent->getProcess() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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.