/**
  * Setter for the console arguments.
  *
  * @param phpucConsoleArgs $args The console arguments.
  *
  * @return void
  */
 public function setConsoleArgs(phpucConsoleArgs $args)
 {
     parent::setConsoleArgs($args);
     $args->setOption('test-case', 'PhpUnderControl_Example_MathTest');
     $args->setOption('test-file', 'MathTest.php');
     $args->setOption('test-dir', 'tests');
 }
 /**
  * Validates all command tasks.
  *
  * @return void
  */
 public function validate()
 {
     // Check that the cc-install-dir exists.
     $path = $this->args->getArgument('cc-install-dir');
     if (!is_dir($path)) {
         throw new phpucValidateException("The CruiseControl directory '{$path}' doesn't exist.");
     }
     parent::validate();
 }
 /**
  * This test checks whether --without-php-documentor option has been set properly
  *
  * @covers phpucPhpDocumentorTask::registerCommandExtension
  *
  * @return void
  */
 public function testPhpDocumentorTaskIsIgnored()
 {
     $this->prepareArgv(array('example', PHPUC_TEST_DIR, '--without-php-documentor'));
     $input = new phpucConsoleInput();
     $input->parse();
     $command = phpucAbstractCommand::createCommand($input->args->command);
     $command->setConsoleArgs($input->args);
     $cmdTasks = $command->createTasks();
     $this->assertPhpucTaskNotOnTheList($cmdTasks, 'phpucPhpDocumentorTask');
 }
Esempio n. 4
0
 /**
  * Performs a single cli request.
  *
  * @return void
  */
 public function run()
 {
     try {
         if ($this->input->parse()) {
             phpucConsoleOutput::set(new phpucConsoleOutput());
             $command = phpucAbstractCommand::createCommand($this->input->args->command);
             $command->setConsoleArgs($this->input->args);
             $command->validate();
             $command->execute();
         }
         exit(0);
     } catch (phpucConsoleException $e) {
         echo $e->getMessage(), PHP_EOL;
         exit(1);
     } catch (phpucExecuteException $e) {
         echo $e->getMessage(), PHP_EOL;
         exit(2);
     } catch (phpucValidateException $e) {
         echo $e->getMessage(), PHP_EOL;
         exit(3);
     } catch (phpucRuntimeException $e) {
         echo $e->getMessage(), PHP_EOL;
         exit(5);
     } catch (Exception $e) {
         echo $e->getMessage(), PHP_EOL;
         exit(4);
     }
 }
 /**
  * Tests that the {@link phpucAbstractCommand#createCommand()} fails with an
  * exception if an invalid command identifier is given.
  * 
  * @return void
  */
 public function testStaticCreateCommandWithInvalidCommandIdFail()
 {
     $commandId = 'foobar';
     $commandIds = $this->globCommandIdsAndClassNames();
     if (isset($commandIds[$commandId])) {
         $this->markTestSkipped("Unexpected command id '{$commandId}' exists.");
     }
     $this->setExpectedException('phpucErrorException', 'Unknown command "foobar" used.');
     phpucAbstractCommand::createCommand($commandId);
 }