/**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * 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();
 }
 /**
  * Does nothing.
  *
  * @return void
  */
 public function execute()
 {
     $out = phpucConsoleOutput::get();
     $out->writeLine('Performing PHP_CodeSniffer task.');
     $projectName = $this->args->getOption('project-name');
     $projectPath = sprintf('%s/projects/%s', $this->args->getArgument('cc-install-dir'), $projectName);
     $out->startList();
     $out->writeListItem('Modifying build file: project/{1}/build.xml', $projectName);
     // Create error log file
     $errorLog = phpucFileUtil::getSysTempDir() . '/checkstyle.error.log';
     $buildFile = new phpucBuildFile($projectPath . '/build.xml', $projectName);
     $buildTarget = $buildFile->createBuildTarget('php-codesniffer');
     $buildTarget->dependOn('lint');
     $execTask = phpucAbstractAntTask::create($buildFile, 'exec');
     $execTask->executable = $this->executable;
     $execTask->error = $errorLog;
     $execTask->output = '${basedir}/build/logs/checkstyle.xml';
     $execTask->argLine = sprintf('--report=checkstyle --standard=%s %s', $this->args->getOption('coding-guideline'), $this->args->getOption('source-dir'));
     $buildTarget->addTask($execTask);
     $buildFile->store();
     $out->writeLine();
 }
 /**
  * Tests the fileset target is generated properly.
  *
  * @covers phpucFilesetAntTask::buildXml
  *
  * @return void
  */
 public function testBuildFilesetTask()
 {
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $target = $buildFile->createBuildTarget('phpuc');
     $includePattern = '**/*.php';
     $filesetTask = phpucAbstractAntTask::create($buildFile, 'fileset');
     $filesetTask->dir = PHPUC_TEST_DIR;
     $filesetTask->include = $includePattern;
     $target->addTask($filesetTask);
     $buildFile->store();
     $sxml = simplexml_load_file($this->fileName);
     $build = $sxml->xpath('/project/target[@name="build"]');
     $phpuc = $sxml->xpath('/project/target[@name="phpuc"]');
     $this->assertEquals(1, count($build));
     $this->assertEquals(1, count($phpuc));
     $this->assertEquals('phpuc', (string) $build[0]['depends']);
     $this->assertEquals('phpuc', (string) $phpuc[0]['name']);
     $fileset = $phpuc[0]->fileset;
     $this->assertType('SimpleXMLElement', $fileset);
     $this->assertEquals(PHPUC_TEST_DIR, (string) $fileset['dir']);
     $include = $fileset->include;
     $this->assertType('SimpleXMLElement', $include);
     $this->assertEquals($includePattern, (string) $include['name']);
 }
Exemplo n.º 5
0
 /**
  * Creates the ant target element for phpunit.
  *
  * @return void
  */
 protected function createAntTarget()
 {
     phpucConsoleOutput::get()->writeListItem('Modifying build file:  project/{1}/build.xml', $this->getProjectName());
     $buildFile = new phpucBuildFile($this->getProjectPath() . '/build.xml');
     $buildTarget = $buildFile->createBuildTarget('phpunit');
     $buildTarget->dependOn('lint');
     $execTask = phpucAbstractAntTask::create($buildFile, 'exec');
     $execTask->executable = $this->executable;
     $execTask->failonerror = true;
     $execTask->argLine = $this->getPhpunitCliArguments();
     $buildTarget->addTask($execTask);
     $buildFile->store();
 }
Exemplo n.º 6
0
 /**
  * Tests the apply target is generated properly with subtasks attached.
  *
  * @covers phpucApplyAntTask::__construct
  * @covers phpucApplyAntTask::buildXml
  *
  * @return void
  */
 public function testBuildApplyTargetWithSubtasksAttached()
 {
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $target = $buildFile->createBuildTarget('phpuc');
     $filesetTask = $this->getMock('phpucFilesetAntTask', array('buildXml'), array(), '', false);
     $filesetTask->expects($this->once())->method('buildXml');
     $taskArgLine = '-l';
     $applyTask = phpucAbstractAntTask::create($buildFile, 'apply');
     $applyTask->dir = PHPUC_TEST_DIR;
     $applyTask->argLine = $taskArgLine;
     $applyTask->failonerror = true;
     $applyTask->logerror = true;
     $applyTask->addTask($filesetTask);
     $target->addTask($applyTask);
     $buildFile->store();
     $sxml = simplexml_load_file($this->fileName);
     $build = $sxml->xpath('/project/target[@name="build"]');
     $phpuc = $sxml->xpath('/project/target[@name="phpuc"]');
     $this->assertEquals(1, count($build));
     $this->assertEquals(1, count($phpuc));
     $this->assertEquals('phpuc', (string) $build[0]['depends']);
     $this->assertEquals('phpuc', (string) $phpuc[0]['name']);
     $apply = $phpuc[0]->apply;
     $this->assertType('SimpleXMLElement', $apply);
     $this->assertEquals('php', (string) $apply['executable']);
     $this->assertEquals('on', (string) $apply['failonerror']);
     $this->assertEquals('on', (string) $apply['logerror']);
     $this->assertEquals(PHPUC_TEST_DIR, (string) $apply['dir']);
     $this->assertType('SimpleXMLElement', $apply->arg);
     $this->assertEquals($taskArgLine, (string) $apply->arg['line']);
 }
 /**
  * Tests setting a value of undefined property
  * in {@link phpucAbstractAntTask::$properties}
  *
  * @covers phpucAbstractAntTask::__set
  * @covers OutOfRangeException
  *
  * @return void
  */
 public function testSetUndefinedPropertyThrowsOutOfRangeException()
 {
     $buildFile = $this->getMock('phpucBuildFile', array(), array(), '', false);
     $exec = phpucAbstractAntTask::create($buildFile, 'exec');
     $this->setExpectedException('OutOfRangeException', 'Unknown or readonly property $fake.');
     $exec->fake = 'foobar';
 }
 /**
  * Tests the exec target is generated properly.
  *
  * @covers phpucExecAntTask::buildXml
  *
  * @return void
  */
 public function testBuildExecTarget()
 {
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $target = $buildFile->createBuildTarget('phpuc');
     $execTask = phpucAbstractAntTask::create($buildFile, 'exec');
     $execTask->executable = 'phpuc';
     $execTask->dir = PHPUC_TEST_DIR;
     $execTask->argLine = 'example /opt/cruisecontrol';
     $execTask->output = PHPUC_TEST_DIR;
     $execTask->failonerror = true;
     $execTask->logerror = true;
     $target->addTask($execTask);
     $buildFile->store();
     $sxml = simplexml_load_file($this->fileName);
     $build = $sxml->xpath('/project/target[@name="build"]');
     $phpuc = $sxml->xpath('/project/target[@name="phpuc"]');
     $this->assertEquals(1, count($build));
     $this->assertEquals(1, count($phpuc));
     $this->assertEquals('phpuc', (string) $build[0]['depends']);
     $this->assertEquals('phpuc', (string) $phpuc[0]['name']);
     $exec = $phpuc[0]->exec;
     $this->assertType('SimpleXMLElement', $exec);
     $this->assertEquals('phpuc', (string) $exec['executable']);
     $this->assertEquals('on', (string) $exec['failonerror']);
     $this->assertEquals('on', (string) $exec['logerror']);
     $this->assertEquals(PHPUC_TEST_DIR, (string) $exec['dir']);
     $this->assertEquals(PHPUC_TEST_DIR, (string) $exec['output']);
     $this->assertType('SimpleXMLElement', $exec->arg);
     $this->assertEquals('example /opt/cruisecontrol', (string) $exec->arg['line']);
 }
Exemplo n.º 9
0
 /**
  * Tests that {@link phpucAbstractAntTask} are properly added to
  * target tasks list
  *
  * @covers phpucBuildTarget::addTask
  * @covers phpucBuildTarget::getTasks
  *
  * @return void
  */
 public function testTargetTasks()
 {
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $target = $buildFile->createBuildTarget('phpuc');
     $execTask = phpucAbstractAntTask::create($buildFile, 'exec');
     $applyTask = phpucAbstractAntTask::create($buildFile, 'apply');
     $target->addTask($execTask);
     $target->addTask($applyTask);
     $this->assertEquals(array($execTask, $applyTask), $target->getTasks());
     $tasks = PHPUnit_Util_Class::getObjectAttribute($target, 'tasks');
     $this->assertEquals(array($execTask, $applyTask), $tasks);
 }
Exemplo n.º 10
0
 /**
  * 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();
 }