11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Console\Question\Question;
14 use Symfony\Component\Console\Question\QuestionFactory;
15 use Symfony\Component\Console\Helper\QuestionHelper;
16 use PHPUnit_Framework_MockObject_MockObject as MockObject;
23 private $questionFactoryMock;
28 private $questionHelperMock;
50 $this->questionFactoryMock = $this->getMockBuilder(QuestionFactory::class)
51 ->disableOriginalConstructor()
52 ->setMethods([
'create'])
54 $this->questionHelperMock = $this->getMockBuilder(QuestionHelper::class)
55 ->disableOriginalConstructor()
57 $this->inputMock = $this->getMockBuilder(InputInterface::class)
58 ->getMockForAbstractClass();
59 $this->outputMock = $this->getMockBuilder(OutputInterface::class)
60 ->getMockForAbstractClass();
63 $this->questionFactoryMock,
64 $this->questionHelperMock
75 $pathQuestionMock = $this->getMockBuilder(Question::class)
76 ->disableOriginalConstructor()
78 $valueQuestionMock = $this->getMockBuilder(Question::class)
79 ->disableOriginalConstructor()
81 $this->inputMock->expects($this->exactly(2))
82 ->method(
'getArgument')
87 ->willReturnOnConsecutiveCalls(
91 $this->questionFactoryMock->expects($this->exactly(2))
94 [[
'question' =>
'Please enter config path: ']],
95 [[
'question' =>
'Please enter value: ']]
97 ->willReturnOnConsecutiveCalls(
103 [
'some/config/path1' =>
'someValue'],
104 $this->model->getValues(
123 $pathQuestionMock = $this->getMockBuilder(Question::class)
124 ->disableOriginalConstructor()
126 $this->inputMock->expects($this->once())
127 ->method(
'getArgument')
129 ->willReturn(
'some/not_exist/config');
130 $this->questionFactoryMock->expects($this->once())
132 ->with([
'question' =>
'Please enter config path: '])
133 ->willReturn($pathQuestionMock);
135 $this->model->getValues(
153 $pathQuestionMock = $this->getMockBuilder(Question::class)
154 ->disableOriginalConstructor()
156 $valueQuestionMock = $this->getMockBuilder(Question::class)
157 ->disableOriginalConstructor()
159 $this->questionHelperMock->expects($this->once())
161 ->with($this->inputMock, $this->outputMock, $valueQuestionMock)
163 $this->inputMock->expects($this->exactly(2))
164 ->method(
'getArgument')
169 ->willReturnOnConsecutiveCalls(
173 $this->questionFactoryMock->expects($this->exactly(2))
176 [[
'question' =>
'Please enter config path: ']],
177 [[
'question' =>
'Please enter value: ']]
179 ->willReturnOnConsecutiveCalls(
184 $this->model->getValues(
const INPUT_ARGUMENT_PATH
const INPUT_ARGUMENT_VALUE