Skip to content

Commit 58f5988

Browse files
author
Grégoire Paqueron
committed
change wrong option show-multiple-choice in hide-multiple-choice
1 parent 91b102e commit 58f5988

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

Command/StartCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ protected function configure()
4444
$this
4545
->setName('start')
4646
->setDescription('Starts a new question set')
47+
->addArgument('categories', InputArgument::IS_ARRAY, 'Which categories do you want (separate multiple with a space)', array())
4748
->addOption('number', null, InputOption::VALUE_OPTIONAL, 'How many questions do you want?', 20)
4849
->addOption('list', 'l', InputOption::VALUE_NONE, 'List categories')
4950
->addOption("training", null, InputOption::VALUE_NONE, "Training mode: the solution is displayed after each question")
50-
->addOption('show-multiple-choice', null, InputOption::VALUE_OPTIONAL, 'Should we tell you when the question is multiple choice?', true)
51-
->addArgument('categories', InputArgument::IS_ARRAY, 'Which categories do you want (separate multiple with a space)', array())
51+
->addOption('hide-multiple-choice', null, InputOption::VALUE_NONE, 'Should we hide the information that the question is multiple choice?')
5252
->addOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Use custom config', null)
5353
;
5454
}
@@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9292
protected function askQuestions(Set $set, InputInterface $input, OutputInterface $output)
9393
{
9494
$questionHelper = $this->getHelper('question');
95-
$showMultipleChoice = $input->getOption('show-multiple-choice');
95+
$hideMultipleChoice = $input->getOption('hide-multiple-choice');
9696
$questionCount = 1;
9797

9898
foreach ($set->getQuestions() as $i => $question) {
@@ -102,12 +102,12 @@ protected function askQuestions(Set $set, InputInterface $input, OutputInterface
102102
$questionCount++,
103103
$question->getCategory(),
104104
$question->getQuestion(),
105-
($showMultipleChoice === true ? "\n".'This question <comment>'.($question->isMultipleChoice() === true ? 'IS' : 'IS NOT')."</comment> multiple choice." : "")
105+
($hideMultipleChoice === true ? "" : "\n".'This question <comment>'.($question->isMultipleChoice() === true ? 'IS' : 'IS NOT')."</comment> multiple choice.")
106106
),
107107
$question->getAnswersLabels()
108108
);
109109

110-
$multiSelect = $showMultipleChoice === true ? $question->isMultipleChoice() : true;
110+
$multiSelect = true === $hideMultipleChoice ? true : $question->isMultipleChoice();
111111
$numericOnly = 1 === array_product(array_map('is_numeric', $question->getAnswersLabels()));
112112
$choiceQuestion->setMultiselect($multiSelect);
113113
$choiceQuestion->setErrorMessage('Answer %s is invalid.');

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ Will only get the questions from the categories "Automated tests" and "Bundles"
4343

4444
Use the category list from [List categories](#list-categories)
4545

46-
### Show if a question has multiple choices
46+
### Hide the information that questions are/aren't multiple choice
4747
```
48-
$ php certificationy.php start --show-multiple-choice
48+
$ php certificationy.php start --hide-multiple-choice
4949
```
5050

51-
![Multiple choices](https://cloud.githubusercontent.com/assets/795661/3308225/721b5324-f679-11e3-8d9d-62ba32cd8e32.png "Multiple choices")
51+
As default, the information will be displayed
52+
53+
![Multiple choice](https://cloud.githubusercontent.com/assets/795661/3308225/721b5324-f679-11e3-8d9d-62ba32cd8e32.png "Multiple choice")
5254

5355
### Set custom configuration file
5456
```
@@ -59,11 +61,11 @@ Will set custom config file
5961

6062
### And all combined
6163
```
62-
$ php certificationy.php start --number=5 --show-multiple-choice "Automated tests" "Bundles"
64+
$ php certificationy.php start --number=5 --hide-multiple-choice "Automated tests" "Bundles"
6365
```
6466

6567
* 5 questions
66-
* We will show if a questions has multiple choices
68+
* We will hide the information that questions are/aren't multiple choice
6769
* Only get questions from category "Automated tests" and "Bundles"
6870

6971
> Note: if you pass --list [-l] then you will ONLY get the category list, regarding your other settings

Tests/Command/StartCommandTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ public function testCanGetQuestions()
7272
$this->assertRegExp('/Starting a new set of 20 questions/', $commandTester->getDisplay());
7373
}
7474

75+
public function testCanHideInformationAboutMultipleChoice()
76+
{
77+
$helper = $this->command->getHelper('question');
78+
$helper->setInputStream($this->getInputStream(str_repeat("0\n", 1)));
79+
80+
$commandTester = new CommandTester($this->command);
81+
$commandTester->execute(array(
82+
'command' => $this->command->getName(),
83+
'--hide-multiple-choice' => null,
84+
'--number' => 1,
85+
));
86+
87+
$output = $commandTester->getDisplay();
88+
$this->assertNotRegExp('/This question IS( NOT)? multiple choice/', $output);
89+
}
90+
7591
protected function getInputStream($input)
7692
{
7793
$stream = fopen('php://memory', 'r+', false);

0 commit comments

Comments
 (0)