@@ 16-54 (lines=39) @@ | ||
13 | { |
|
14 | protected $command; |
|
15 | ||
16 | public function setUp() |
|
17 | { |
|
18 | parent::setUp(); |
|
19 | ||
20 | $this->command = new class extends AddNotificationByHost { |
|
21 | private $answers = []; |
|
22 | private $answer = 0; |
|
23 | public function answers($answers) { |
|
24 | $this->answer = 0; |
|
25 | $this->answers = $answers; |
|
26 | } |
|
27 | public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) |
|
28 | { |
|
29 | echo $question."\n"; |
|
30 | $result = $this->answers[$this->answer]; |
|
31 | if($multiple) { |
|
32 | if(!is_array($this->answers[$this->answer])) { |
|
33 | $result = [$this->answers[$this->answer]]; |
|
34 | } |
|
35 | } |
|
36 | $this->answer ++; |
|
37 | return $result; |
|
38 | } |
|
39 | public function confirm($question, $default = false) |
|
40 | { |
|
41 | echo $question."\n"; |
|
42 | return $this->answers[$this->answer ++]; |
|
43 | } |
|
44 | ||
45 | public function ask($question, $default = null) { |
|
46 | echo $question."\n"; |
|
47 | return $this->answers[$this->answer ++]; |
|
48 | } |
|
49 | }; |
|
50 | ||
51 | $this->app->bind('command.server-monitor:add-notification-host', function () { |
|
52 | return $this->command; |
|
53 | }); |
|
54 | } |
|
55 | ||
56 | /** @test */ |
|
57 | public function it_can_notify_host_empty() |
@@ 17-56 (lines=40) @@ | ||
14 | /** @var \TheCodingMachine\ServerMonitorPluginNotificationByHost\Commands\ListNotifications|m\Mock */ |
|
15 | protected $command; |
|
16 | ||
17 | public function setUp() { |
|
18 | parent::setUp(); |
|
19 | $this->command = new class extends ListNotifications { |
|
20 | ||
21 | private $answers = []; |
|
22 | ||
23 | private $answer = 0; |
|
24 | ||
25 | public function answers($answers) { |
|
26 | $this->answer = 0; |
|
27 | $this->answers = $answers; |
|
28 | } |
|
29 | ||
30 | public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) { |
|
31 | echo $question . "\n"; |
|
32 | $result = $this->answers[$this->answer]; |
|
33 | if ($multiple) { |
|
34 | if (!is_array($this->answers[$this->answer])) { |
|
35 | $result = [$this->answers[$this->answer]]; |
|
36 | } |
|
37 | } |
|
38 | $this->answer++; |
|
39 | return $result; |
|
40 | } |
|
41 | ||
42 | public function confirm($question, $default = false) { |
|
43 | echo $question . "\n"; |
|
44 | return $this->answers[$this->answer++]; |
|
45 | } |
|
46 | ||
47 | public function ask($question, $default = null) { |
|
48 | echo $question . "\n"; |
|
49 | return $this->answers[$this->answer++]; |
|
50 | } |
|
51 | }; |
|
52 | ||
53 | $this->app->bind('command.server-monitor:list-notifications', function () { |
|
54 | return $this->command; |
|
55 | }); |
|
56 | } |
|
57 | ||
58 | /** @test */ |
|
59 | public function it_check_no_data() { |