|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the MIT license. For more information, see |
|
17
|
|
|
* <http://www.doctrine-project.org>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace BaleenTest\Cli\CommandBus\Timeline; |
|
21
|
|
|
|
|
22
|
|
|
use Baleen\Cli\CommandBus\Timeline\AbstractTimelineCommand; |
|
23
|
|
|
use Baleen\Cli\CommandBus\Timeline\ExecuteMessage; |
|
24
|
|
|
use Baleen\Migrations\Migration\Options; |
|
25
|
|
|
use Baleen\Migrations\Timeline; |
|
26
|
|
|
use Baleen\Migrations\Version; |
|
27
|
|
|
use BaleenTest\Cli\CommandBus\MessageTestCase; |
|
28
|
|
|
use Mockery as m; |
|
29
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
30
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Class ExecuteMessageTest |
|
34
|
|
|
* @author Gabriel Somoza <[email protected]> |
|
35
|
|
|
*/ |
|
36
|
|
|
class ExecuteMessageTest extends MessageTestCase |
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Must test the constructor and assert implemented interfaces |
|
41
|
|
|
*/ |
|
42
|
|
|
public function testConstructor() |
|
43
|
|
|
{ |
|
44
|
|
|
$instance = new ExecuteMessage(); |
|
45
|
|
|
$this->assertInstanceOf(AbstractTimelineCommand::class, $instance); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* getClassName must return a string with the FQN of the command class being tested |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function getClassName() |
|
53
|
|
|
{ |
|
54
|
|
|
return ExecuteMessage::class; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Must return an array in the format: |
|
59
|
|
|
* |
|
60
|
|
|
* [ |
|
61
|
|
|
* 'name' => 'functionName', // required |
|
62
|
|
|
* 'with' => [arguments for with] // optional |
|
63
|
|
|
* 'return' => return value // optional, defaults to return self |
|
64
|
|
|
* 'times' => number of times it will be invoked |
|
65
|
|
|
* ] |
|
66
|
|
|
* |
|
67
|
|
|
* @return array |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function getExpectations() |
|
70
|
|
|
{ |
|
71
|
|
|
return [ |
|
72
|
|
|
[ 'name' => 'setName', |
|
73
|
|
|
'with' => 'timeline:execute', |
|
74
|
|
|
], |
|
75
|
|
|
[ 'name' => 'setAliases', |
|
76
|
|
|
'with' => [['exec', 'execute']], |
|
77
|
|
|
], |
|
78
|
|
|
[ 'name' => 'setDescription', |
|
79
|
|
|
'with' => m::type('string'), |
|
80
|
|
|
], |
|
81
|
|
|
[ 'name' => 'addOption', |
|
82
|
|
|
'with' => [ExecuteMessage::OPT_DRY_RUN, 'd', InputOption::VALUE_NONE, m::type('string')], |
|
83
|
|
|
], |
|
84
|
|
|
[ 'name' => 'addOption', |
|
85
|
|
|
'with' => [ExecuteMessage::OPT_NO_STORAGE, m::any(), InputOption::VALUE_NONE, m::type('string')], |
|
86
|
|
|
], |
|
87
|
|
|
[ 'name' => 'addArgument', |
|
88
|
|
|
'with' => [ExecuteMessage::ARG_VERSION, InputArgument::REQUIRED, m::type('string')], |
|
89
|
|
|
], |
|
90
|
|
|
[ 'name' => 'addArgument', |
|
91
|
|
|
'with' => [ |
|
92
|
|
|
ExecuteMessage::ARG_DIRECTION, |
|
93
|
|
|
InputArgument::OPTIONAL, |
|
94
|
|
|
m::type('string'), |
|
95
|
|
|
Options::DIRECTION_UP, |
|
96
|
|
|
], |
|
97
|
|
|
], |
|
98
|
|
|
]; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|