ConsoleTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. use Symfony\Component\Console\Application;
  3. use Symfony\Component\Console\Tester\CommandTester;
  4. use Chash\Command\Files\CleanConfigFilesCommand;
  5. class ConsoleTest extends PHPUnit_Framework_TestCase
  6. {
  7. public function setUp()
  8. {
  9. $configurationFileContent = file_get_contents(__DIR__.'/../Resources/configuration.php');
  10. vfsStreamWrapper::register();
  11. $structure = array(
  12. 'chamilo' => array(
  13. 'config' => array(
  14. 'configuration.php' => $configurationFileContent,
  15. ),
  16. 'tests' => array(),
  17. 'data' => array('courses')
  18. )
  19. );
  20. vfsStream::setup('root', null, $structure);
  21. }
  22. public function testListCommand()
  23. {
  24. $application = new Application();
  25. $helpers = array(
  26. 'configuration' => new Chash\Helpers\ConfigurationHelper()
  27. );
  28. $helperSet = $application->getHelperSet();
  29. foreach ($helpers as $name => $helper) {
  30. $helperSet->set($helper, $name);
  31. }
  32. $application->add(new CleanConfigFilesCommand());
  33. $command = $application->find('files:clean_config_files');
  34. $this->assertEquals('Chash\Command\Files\CleanConfigFilesCommand', get_class($command));
  35. /* $commandTester = new CommandTester($command);
  36. $returnCode = $commandTester->execute(
  37. array(
  38. 'command' => $command->getName(),
  39. '--conf' => 'chamilo/config/configuration.php'
  40. )
  41. );*/
  42. // var_dump(realpath(__DIR__.'/../../Resources/configuration.php'));
  43. // $this->assertRegExp('/11/', $commandTester->getDisplay());
  44. }
  45. }