예제 #1
0
 /**
  * Tests that dependencies on given target are defined properly
  *
  * @covers phpucBuildFile::processTargetDependencies
  *
  * @return void
  */
 public function testProcessTargetDependencies()
 {
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $lint = $buildFile->createBuildTarget('lint');
     $buildFile->store();
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $phpcs = $buildFile->createBuildTarget('phpcs');
     $buildFile->store();
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $phpuc = $buildFile->createBuildTarget('phpuc');
     $phpuc->dependOn('lint');
     $phpuc->dependOn('phpcs');
     $buildFile->store();
     $sxml = simplexml_load_file($this->fileName);
     $build = $sxml->xpath('/project/target[@name="phpuc"]');
     $this->assertEquals('lint,phpcs', (string) $build[0]['depends']);
 }
예제 #2
0
 /**
  * Tests that dependency is properly set on build target
  *
  * @covers phpucBuildTarget::dependOn
  *
  * @return void
  */
 public function testSetDependencyOnExistingTarget()
 {
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $lint = $buildFile->createBuildTarget('lint');
     $buildFile->store();
     $buildFile = new phpucBuildFile($this->fileName, $this->projectName);
     $phpuc = $buildFile->createBuildTarget('phpuc');
     $this->assertEquals(array(), $phpuc->depends);
     $phpuc->dependOn('lint');
     $buildFile->store();
     $this->assertEquals(array('lint'), $phpuc->depends);
 }
 /**
  * Initializes a clean console args object and creates a project dummy.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->projectDir = PHPUC_TEST_DIR . '/projects/php-under-control';
     $options = array('example', '--pear-executables-dir', PHPUC_TEST_DIR . '/bin', '--project-name', $this->projectName);
     foreach ($this->options as $option) {
         $options[] = $option;
     }
     $options[] = PHPUC_TEST_DIR;
     $this->prepareArgv($options);
     $input = new phpucConsoleInput();
     $input->parse();
     $this->args = $input->args;
     $this->createTestDirectories(array('projects', "projects/{$this->projectName}"));
     $buildFile = new phpucBuildFile($this->projectDir . '/build.xml', $this->projectName);
     $buildFile->store();
 }
예제 #4
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();
 }