Skip to content

Commit

Permalink
Merge pull request #5 from certificationy/uncouple-data
Browse files Browse the repository at this point in the history
prepare for 1.1
  • Loading branch information
mickaelandrieu committed Feb 9, 2015
2 parents c5940dd + d9e5753 commit d421248
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm

before_script:
Expand Down
18 changes: 14 additions & 4 deletions Command/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function configure()
->setDescription('Starts a new question set')
->addOption('number', null, InputOption::VALUE_OPTIONAL, 'How many questions do you want?', 20)
->addOption('list', 'l', InputOption::VALUE_NONE, 'List categories')
->addOption('show-multiple-choice', null, InputOption::VALUE_OPTIONAL, 'Should we tell you when the question is multiple choice?', true)
->addOption('show-multiple-choice', null, InputOption::VALUE_OPTIONAL, 'Should we tell you when the question is multiple choice?', true)
->addArgument('categories', InputArgument::IS_ARRAY, 'Which categories do you want (separate multiple with a space)', array())
;
}
Expand All @@ -56,18 +56,18 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('list')) {
$output->writeln(Loader::getCategories());
$output->writeln(Loader::getCategories($this->path()));
return ;
}

$categories = $input->getArgument('categories');
$number = $input->getOption('number');

$set = Loader::init($number, $categories);
$set = Loader::init($number, $categories, $this->path());

if ($set->getQuestions()) {
$output->writeln(
sprintf('Starting a new set of <info>%s</info> questions (available questions: <info>%s</info>)', count($set->getQuestions()), Loader::count())
sprintf('Starting a new set of <info>%s</info> questions (available questions: <info>%s</info>)', count($set->getQuestions()), Loader::count(array(), $this->path()))
);

$this->askQuestions($set, $input, $output);
Expand Down Expand Up @@ -152,5 +152,15 @@ protected function displayResults(Set $set, OutputInterface $output)
);
}
}

/**
* Returns configuration file path
*
* @return String $path The configuration filepath
*/
protected function path()
{
return dirname(__DIR__).DIRECTORY_SEPARATOR.'config.yml';
}
}

10 changes: 8 additions & 2 deletions Tests/Command/StartCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ class StartCommandTest extends \PHPUnit_Framework_TestCase
*/
private $command;

/**
* @var string config filepath
*/
private $configFile;

public function setUp()
{
$app = new Application();
$app->add(new StartCommand());
$this->command = $app->find('start');
$this->configFile = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config.yml';
}

public function testCanListCategories()
Expand All @@ -47,7 +53,7 @@ public function testCanListCategories()

$output = $commandTester->getDisplay();
$this->assertRegExp('/Twig/', $output);
$this->assertCount(count(Loader::getCategories()) + 1, explode("\n", $output));
$this->assertCount(count(Loader::getCategories($this->configFile)) + 1, explode("\n", $output));
}

public function testCanGetQuestions()
Expand All @@ -73,4 +79,4 @@ protected function getInputStream($input)
return $stream;
}

}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
],
"require": {
"php": ">=5.3.3",
"certificationy/certificationy": ">=1.0"
"certificationy/certificationy": "dev-master",
"certificationy/symfony-pack": "dev-master",
"certificationy/php-pack": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.1"
Expand Down
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
paths: ["vendor/certificationy/symfony-pack/data", "vendor/certificationy/php-pack/data"]

0 comments on commit d421248

Please sign in to comment.