コード例 #1
0
 /**
  * Creates the api documentation build directory.
  *
  * @return void
  * @throws phpucExecuteException If the execution fails.
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing PhpDocumentor task.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $projectName = $this->args->getOption('project-name');
     $projectPath = sprintf('%s/projects/%s', $installDir, $projectName);
     $out->startList();
     $out->writeListItem('Creating apidoc dir:  project/{1}/build/api', $projectName);
     mkdir($projectPath . '/build/api', 0755, true);
     $out->writeListItem('Modifying build file: project/{1}/build.xml', $projectName);
     $buildFile = new phpucBuildFile($projectPath . '/build.xml');
     $buildTarget = $buildFile->createBuildTarget('php-documentor');
     $buildTarget->dependOn('lint');
     $execTask = phpucAbstractAntTask::create($buildFile, 'exec');
     $execTask->executable = $this->executable;
     $execTask->logerror = true;
     $execTask->argLine = sprintf('--title \'${ant.project.name}\' -ue on -t ${basedir}/build/api -d %s ' . '-tb \'%s/phpdoc\' -o HTML:Phpuc:phpuc', $this->args->getOption('source-dir'), PHPUC_DATA_DIR);
     $buildTarget->addTask($execTask);
     $buildFile->store();
     $out->writeListItem('Modifying config file:          config.xml');
     $configFile = new phpucConfigFile($installDir . '/config.xml');
     $configProject = $configFile->getProject($projectName);
     $publisher = $configProject->createArtifactsPublisher();
     $publisher->dir = 'projects/${project.name}/build/api';
     $publisher->subdirectory = 'api';
     if ($this->artifacts) {
         $publisher->dest = 'artifacts/${project.name}';
     } else {
         $publisher->dest = 'logs/${project.name}';
     }
     $configFile->store();
     $out->writeLine();
 }
コード例 #2
0
ファイル: GraphTask.php プロジェクト: Tjorriemorrie/app
 /**
  * Performs the primary task and adds an execute publisher to the config.xml.
  * 
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing ezcGraph task.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $projectName = $this->args->getOption('project-name');
     $out->startList();
     $out->writeListItem('Modifying config file: config.xml');
     $configFile = new phpucConfigFile($installDir . '/config.xml');
     $configProject = $configFile->getProject($projectName);
     $publisher = $configProject->createExecutePublisher();
     $binary = sprintf('%s/phpuc', PHPUC_BIN_DIR);
     if (phpucFileUtil::getOS() === phpucFileUtil::OS_WINDOWS) {
         $binary .= '.bat';
     } else {
         if (!file_exists($binary)) {
             $binary .= '.php';
         }
     }
     // Build default command string
     $command = sprintf('%s graph logs/${project.name}', $binary);
     // Check for an artifacts directory
     if ($this->artifacts) {
         $command .= ' artifacts/${project.name}';
     }
     $publisher->command = $command;
     $configFile->store();
     $out->writeLine();
 }
コード例 #3
0
 /**
  * Creates a new example project with test files.
  *
  * @return void
  * @throws phpucExecuteException If the execution fails.
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing example task.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $projectName = $this->args->getOption('project-name');
     $projectPath = sprintf('%s/projects/%s', $installDir, $projectName);
     $out->startList();
     $out->writeListItem('Creating source directory:  project/{1}/source/src', $projectName);
     mkdir($projectPath . '/source/src');
     $out->writeListItem('Creating tests directory:   project/{1}/source/tests', $projectName);
     mkdir($projectPath . '/source/tests');
     $out->writeListItem('Creating source class:      project/{1}/source/src/Math.php', $projectName);
     file_put_contents($projectPath . '/source/src/Math.php', file_get_contents(PHPUC_DATA_DIR . '/example/src/Math.php'));
     $out->writeListItem('Creating test class:        project/{1}/source/tests/MathTest.php', $projectName);
     file_put_contents($projectPath . '/source/tests/MathTest.php', file_get_contents(PHPUC_DATA_DIR . '/example/tests/MathTest.php'));
     $out->writeListItem('Modifying config file:      config.xml');
     $configXml = new DOMDocument();
     $configXml->preserveWhiteSpace = false;
     $configXml->load($installDir . '/config.xml');
     $alwaysbuild = $configXml->createElement('alwaysbuild');
     $xpath = new DOMXPath($configXml);
     $modifications = $xpath->query(sprintf('/cruisecontrol/project[@name="%s"]/modificationset', $projectName))->item(0);
     $modifications->appendChild($alwaysbuild);
     $configXml->formatOutput = true;
     $configXml->save($installDir . '/config.xml');
     $out->writeLine();
 }
コード例 #4
0
 /**
  * Tests the static registry methods.
  *
  * @return void
  */
 public function testStaticGetSetRegistryMethod()
 {
     // Keep current for restore
     $old = phpucConsoleOutput::get();
     $output = new phpucConsoleOutput();
     $this->assertNotSame($output, phpucConsoleOutput::get());
     phpucConsoleOutput::set($output);
     $this->assertSame($output, phpucConsoleOutput::get());
     // Restore
     phpucConsoleOutput::set($old);
 }
コード例 #5
0
ファイル: CodeBrowserTask.php プロジェクト: Tjorriemorrie/app
 /**
  * Performs the primary task and adds an execute publisher to the config.xml.
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing PHP_CodeBrowser task.');
     $out->startList();
     $out->writeListItem('Creating browser dir: project/{1}/build/php-code-browser', $this->args->getOption('project-name'));
     $this->createCodeBrowserBuildDirectory();
     $out->writeListItem('Modifying config file: config.xml');
     $this->createCodeBrowserExecutePublisher();
     $this->createCodeBrowserArtifactsPublisher();
     $out->writeLine();
 }
コード例 #6
0
ファイル: LintTask.php プロジェクト: yusufchang/app
 /**
  * Performs php files syntax check using php lint.
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing PHP lint task.');
     $out->startList();
     $projectName = $this->args->getOption('project-name');
     $projectPath = sprintf('%s/projects/%s', $this->args->getArgument('cc-install-dir'), $this->args->getOption('project-name'));
     $out->writeListItem('Modifying build file: project/{1}/build.xml', $projectName);
     $buildFile = new phpucBuildFile("{$projectPath}/build.xml");
     $buildTarget = $buildFile->createBuildTarget('lint');
     $filesetTask = phpucAbstractAntTask::create($buildFile, 'fileset');
     $filesetTask->include = '**/*.php';
     $applyTask = phpucAbstractAntTask::create($buildFile, 'apply');
     $applyTask->argLine = '-l';
     $applyTask->failonerror = true;
     $applyTask->logerror = true;
     $applyTask->addTask($filesetTask);
     $buildTarget->addTask($applyTask);
     $buildFile->store();
     $out->writeLine();
 }
コード例 #7
0
ファイル: CheckoutTask.php プロジェクト: Tjorriemorrie/app
 /**
  * Performs a project checkout against the specified repository.
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing checkout task.');
     $out->startList();
     // Get current working dir
     $cwd = getcwd();
     $out->writeListItem('Checking out project.');
     $projectPath = sprintf('%s/projects/%s', $this->args->getArgument('cc-install-dir'), $this->args->getOption('project-name'));
     // Switch working dir to the CruiseControl project directory
     chdir($projectPath);
     $checkout = phpucAbstractCheckout::createCheckout($this->args);
     $checkout->checkout();
     chdir($cwd);
     $out->writeListItem('Preparing config.xml file.');
     $fileName = sprintf('%s/config.xml', $this->args->getArgument('cc-install-dir'));
     $config = new phpucConfigFile($fileName);
     $project = $config->getProject($this->args->getOption('project-name'));
     $strapper = $project->createBootStrapper();
     $strapper->localWorkingCopy = "{$projectPath}/source";
     $strapper->strapperType = $this->args->getOption('version-control');
     $trigger = $project->createBuildTrigger();
     $trigger->localWorkingCopy = "{$projectPath}/source";
     $trigger->triggerType = $this->args->getOption('version-control');
     $config->store();
     $out->writeListItem('Preparing build.xml checkout target.');
     $buildFile = new phpucBuildFile("{$projectPath}/build.xml");
     $buildTarget = $buildFile->createBuildTarget('checkout');
     $execTask = phpucAbstractAntTask::create($buildFile, 'exec');
     $execTask->executable = phpucFileUtil::findExecutable($this->args->getOption('version-control'));
     $execTask->argLine = $checkout->getUpdateCommand();
     $execTask->failonerror = true;
     $buildTarget->addTask($execTask);
     $buildFile->store();
     $out->writeLine();
 }
コード例 #8
0
 /**
  * Validates the existing PHPUnit version.
  *
  * @return void
  */
 protected function doValidate()
 {
     $binary = basename($this->executable);
     if (($execdir = dirname($this->executable)) !== '.') {
         chdir($execdir);
         if (phpucFileUtil::getOS() === phpucFileUtil::OS_UNIX) {
             $binary = "./{$binary}";
         }
     }
     // Check Xdebug installation
     if (extension_loaded('xdebug') === false) {
         phpucConsoleOutput::get()->writeLine('NOTICE: The xdebug extension is not installed. For coverage');
         phpucConsoleOutput::get()->writeLine('you must install xdebug with the following command:');
         phpucConsoleOutput::get()->writeLine('  pecl install pecl/xdebug');
         $this->properties['coverage'] = false;
     }
 }
コード例 #9
0
 /**
  * Overrides all files from <b>$files</b> in the cc webapps folder.
  *
  * @return void
  * @throws phpucExecuteException If the execution fails.
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing modify file task.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $out->startList();
     foreach ($this->files as $file) {
         $filepath = $installDir . $file;
         if (file_exists("{$filepath}.orig") === false) {
             $out->writeListItem('Creating backup "{1}".', $file);
             copy($filepath, "{$filepath}.orig");
         }
         $out->writeListItem('Modifying file "{1}"', $file);
         $fileUtil = new phpucFileCopyUtil();
         $fileUtil->copy(PHPUC_DATA_DIR . '/' . $file, $filepath);
     }
     $out->writeLine();
 }
コード例 #10
0
ファイル: PhpUnderControl.php プロジェクト: Tjorriemorrie/app
 /**
  * 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);
     }
 }
コード例 #11
0
 /**
  * Creates the some directories in the CruiseControl folder. 
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing CruiseControl task.');
     // Get root directory.
     $installDir = sprintf('%s/webapps/cruisecontrol/', $this->args->getArgument('cc-install-dir'));
     $out->startList();
     foreach ($this->directories as $directory) {
         // Skip for existing directories.
         if (is_dir($installDir . $directory)) {
             continue;
         }
         $out->writeListItem('Creating directory "webapps/cruisecontrol/{1}', $directory);
         mkdir($installDir . $directory);
     }
     $out->writeLine();
 }
コード例 #12
0
 /**
  * Adds a new project to CruiseControl.
  * 
  * This method creates the base directory structure for a CruiseControl
  * project and adds this project to the CruiseControl config.xml file.
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing project task.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $projectName = $this->args->getOption('project-name');
     $projectPath = sprintf('%s/projects/%s', $installDir, $projectName);
     $out->startList();
     $out->writeListItem('Creating project directory: projects/{1}', $projectName);
     mkdir($projectPath);
     $out->writeListItem('Creating source directory:  projects/{1}/source', $projectName);
     mkdir($projectPath . '/source');
     $out->writeListItem('Creating build directory:   projects/{1}/build', $projectName);
     mkdir($projectPath . '/build');
     $out->writeListItem('Creating log directory:     projects/{1}/build/logs', $projectName);
     mkdir($projectPath . '/build/logs');
     $out->writeListItem('Creating build file:        projects/{1}/build.xml', $projectName);
     $buildFile = new phpucBuildFile($projectPath . '/build.xml', $projectName);
     $buildFile->store();
     $out->writeListItem('Creating backup of file:    config.xml.orig');
     @unlink($installDir . '/config.xml.orig');
     copy($installDir . '/config.xml', $installDir . '/config.xml.orig');
     $out->writeListItem('Searching ant directory');
     if (!($anthome = $this->getAntHome($installDir))) {
         throw new phpucExecuteException('ERROR: Cannot locate ant directory.');
     }
     $out->writeListItem('Modifying project file:     config.xml');
     $config = new phpucConfigFile($installDir . '/config.xml');
     $project = $config->createProject($projectName);
     $project->interval = $this->args->getOption('schedule-interval');
     $project->anthome = $anthome;
     if ($this->args->hasOption('ant-script')) {
         $project->antscript = $this->args->getOption('ant-script');
     }
     $config->store();
     $out->writeLine();
 }
コード例 #13
0
 /**
  * Installs linux init script for cruisecontrol
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Setting up Cruisecontrol start-up script.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $initDir = $this->args->getArgument('init-dir');
     $javaHome = $this->args->getOption('java-home');
     $ccUser = $this->args->getOption('cc-user');
     $ccBin = $this->args->getOption('cc-bin');
     $ccScript = file_get_contents(PHPUC_DATA_DIR . '/template/cruisecontrol.sh');
     if (!$ccScript) {
         throw new phpucTaskException('Cannot access Cruisecontrol init script template.');
     }
     $ccScript = str_replace('%cc-install-dir%', $installDir, $ccScript);
     $ccScript = str_replace('%java-home%', $javaHome, $ccScript);
     $ccScript = str_replace('%run-as-user%', $ccUser, $ccScript);
     $ccScript = str_replace('%cc-bin%', $ccBin, $ccScript);
     $result = file_put_contents("{$initDir}/cruisecontrol", $ccScript);
     if (!$result) {
         throw new phpucTaskException('Cruisecontrol init script could not be saved.');
     }
     $out->writeLine('Making the script executable.');
     chmod("{$initDir}/cruisecontrol", 0755);
 }
コード例 #14
0
 /**
  * Initializes the test environment.
  *
  * @return void
  */
 public static function init()
 {
     // Load phpUnderControl base class
     include_once PHPUC_SOURCE . '/PhpUnderControl.php';
     include_once PHPUC_SOURCE . '/Util/Autoloader.php';
     // Register autoload
     $autoloader = new phpucAutoloader();
     spl_autoload_register(array($autoloader, 'autoload'));
     // Load ezcBase class
     if (file_exists(PHPUC_EZC_BASE)) {
         include_once PHPUC_EZC_BASE;
         spl_autoload_register(array('ezcBase', 'autoload'));
     }
     include_once dirname(__FILE__) . '/ConsoleOutputBuffer.php';
     phpucConsoleOutput::set(new phpucConsoleOutputBuffer());
     if (!is_dir(PHPUC_TEST_DIR)) {
         mkdir(PHPUC_TEST_DIR);
     }
     self::$windows = phpucFileUtil::getOS() === phpucFileUtil::OS_WINDOWS;
 }
コード例 #15
0
ファイル: ConsoleOutput.php プロジェクト: yusufchang/app
 /**
  * Sets the default console output instance.
  *
  * @param phpucConsoleOutput $output A console output implementation.
  * 
  * @return void
  */
 public static function set(phpucConsoleOutput $output)
 {
     self::$output = $output;
 }
コード例 #16
0
 /**
  * Copies all files from the <b>$files</b> properties into the cc webapps
  * folder.
  *
  * @return void
  * @throws phpucExecuteException If the execution fails.
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing create file task.');
     $installDir = $this->args->getArgument('cc-install-dir');
     $out->startList();
     foreach ($this->files as $file) {
         $filepath = $installDir . $file;
         $out->writeListItem('Creating file "{1}"', $file);
         file_put_contents($filepath, file_get_contents(PHPUC_DATA_DIR . '/' . $file));
     }
     $out->writeLine();
 }
コード例 #17
0
 /**
  * Validates the existing code sniffer version.
  *
  * @return void
  */
 protected function doValidate()
 {
     $cwd = $this->getWorkingDirectory();
     $binary = basename($this->executable);
     if (($execdir = dirname($this->executable)) !== '.') {
         chdir($execdir);
         if (phpucFileUtil::getOS() === phpucFileUtil::OS_UNIX) {
             $binary = "./{$binary}";
         }
     }
     $regexp = '/version\\s+([0-9\\.]+(RC[0-9])?)/';
     $retval = exec(escapeshellcmd("{$binary} --version"));
     chdir($cwd);
     if (preg_match($regexp, $retval, $match) === 0) {
         phpucConsoleOutput::get()->writeLine('WARNING: Cannot identify PHP_CodeSniffer version.');
         // Assume valid version
         $version = self::CODE_SNIFFER_VERSION;
     } else {
         $version = $match[1];
     }
     if (version_compare($version, self::CODE_SNIFFER_VERSION) < 0) {
         throw new phpucValidateException(sprintf('PHP_CodeSniffer version %s or higher required.' . ' Given version is "%s".', self::CODE_SNIFFER_VERSION, $version));
     }
 }