/**
  * Tests the {@link phpucConfigFile::createProject()} and the 
  * {@link phpucConfigFile::getProject()} methods. 
  *
  * @return void
  */
 public function testCreateProject()
 {
     $this->createTestFile('/config.xml', $this->testXml);
     $config = new phpucConfigFile($this->testFile);
     $project = $config->createProject('phpUnderControl');
     $this->assertType('phpucConfigProject', $project);
     $config->store();
     $this->assertXmlStringNotEqualsXmlString($this->testXml, file_get_contents($this->testFile));
     // Now try to reload the config and read the new project
     $config = new phpucConfigFile($this->testFile);
     $project = $config->getProject('phpUnderControl');
     $this->assertType('phpucConfigProject', $project);
 }
 /**
  * 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();
 }