|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Slick\Mvc\Console\Command\Task; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\Exception\Example\FailureException; |
|
6
|
|
|
use Slick\Mvc\Console\Command\Task\AskForWebRoot; |
|
7
|
|
|
use PhpSpec\ObjectBehavior; |
|
8
|
|
|
use Prophecy\Argument; |
|
9
|
|
|
use Slick\Mvc\Console\Command\TaskInterface; |
|
10
|
|
|
use Slick\Mvc\Console\Exception\OperationAbortedException; |
|
11
|
|
|
use Symfony\Component\Console\Command\Command; |
|
12
|
|
|
use Symfony\Component\Console\Helper\QuestionHelper; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
14
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Question\ConfirmationQuestion; |
|
16
|
|
|
use Symfony\Component\Console\Question\Question; |
|
17
|
|
|
|
|
18
|
|
|
class AskForWebRootSpec extends ObjectBehavior |
|
19
|
|
|
{ |
|
20
|
|
|
|
|
21
|
|
|
function let(Command $command) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->beConstructedWith($command); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
function it_is_initializable() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->shouldHaveType(AskForWebRoot::class); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function its_a_command_task() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->shouldBeAnInstanceOf(TaskInterface::class); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_asks_for_http_server_document_root_path( |
|
37
|
|
|
Command $command, |
|
38
|
|
|
QuestionHelper $helper, |
|
39
|
|
|
InputInterface $input, |
|
40
|
|
|
OutputInterface $output |
|
41
|
|
|
) { |
|
42
|
|
|
|
|
43
|
|
|
$expected = 'public'; |
|
44
|
|
|
$this->setUp($expected, $command, $helper, $input, $output); |
|
45
|
|
|
$this->execute($input, $output)->shouldBe($expected); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
function it_asks_for_override_if_index_file_exists( |
|
49
|
|
|
Command $command, |
|
50
|
|
|
QuestionHelper $helper, |
|
51
|
|
|
InputInterface $input, |
|
52
|
|
|
OutputInterface $output |
|
53
|
|
|
) { |
|
54
|
|
|
$command->getHelper('question') |
|
55
|
|
|
->shouldBeCalled() |
|
56
|
|
|
->willReturn($helper); |
|
57
|
|
|
|
|
58
|
|
|
$helper->ask($input, $output, Argument::type(ConfirmationQuestion::class)) |
|
59
|
|
|
->shouldBeCalled() |
|
60
|
|
|
->willReturn(false); |
|
61
|
|
|
|
|
62
|
|
|
$this->shouldThrow(OperationAbortedException::class) |
|
63
|
|
|
->during('check', ['features/app/webroot', $input, $output]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function it_check_for_index_file_in_folder( |
|
67
|
|
|
InputInterface $input, |
|
68
|
|
|
OutputInterface $output |
|
69
|
|
|
) { |
|
70
|
|
|
|
|
71
|
|
|
$this->check('webroot', $input, $output)->shouldBe(true); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
private function validateQuestion(Question $question) |
|
75
|
|
|
{ |
|
76
|
|
|
$message = "What's the application document root? (webroot): "; |
|
77
|
|
|
if ($question->getQuestion() !== $message) { |
|
78
|
|
|
throw new FailureException( |
|
79
|
|
|
"Expected \"{$message}\" question, " . |
|
80
|
|
|
"but got \"{$question->getQuestion()}\"" |
|
81
|
|
|
); |
|
82
|
|
|
|
|
83
|
|
|
}; |
|
84
|
|
|
return true; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
private function setUp( |
|
88
|
|
|
$result, |
|
89
|
|
|
Command $command, |
|
90
|
|
|
QuestionHelper $helper, |
|
91
|
|
|
InputInterface $input, |
|
92
|
|
|
OutputInterface $output |
|
93
|
|
|
) |
|
94
|
|
|
{ |
|
95
|
|
|
$closure = function (Question $object) {return $this->validateQuestion($object);}; |
|
96
|
|
|
$command->getHelper('question') |
|
|
|
|
|
|
97
|
|
|
->shouldBeCalled() |
|
98
|
|
|
->willReturn($helper); |
|
99
|
|
|
$helper->ask( |
|
100
|
|
|
$input, |
|
101
|
|
|
$output, |
|
102
|
|
|
Argument::that($closure) |
|
103
|
|
|
) |
|
104
|
|
|
->shouldBeCalled() |
|
105
|
|
|
->willReturn($result); |
|
106
|
|
|
$this->beConstructedWith($command); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.