Esempio n. 1
0
 /**
  * @covers PHPUnit::execute
  */
 public function testExecute_CreateDuplicateBuild()
 {
     $build = new Build();
     $build->setId(1);
     $build->setProject(101);
     $build->setCommitId('abcde');
     $build->setStatus(Build::STATUS_FAILED);
     $build->setLog('Test');
     $build->setBranch('example_branch');
     $build->setStarted(new \DateTime());
     $build->setFinished(new \DateTime());
     $build->setCommitMessage('test');
     $build->setCommitterEmail('*****@*****.**');
     $build->setExtra(json_encode(array('item1' => 1001)));
     $returnValue = $this->testedService->createDuplicateBuild($build);
     $this->assertNotEquals($build->getId(), $returnValue->getId());
     $this->assertEquals($build->getProjectId(), $returnValue->getProjectId());
     $this->assertEquals($build->getCommitId(), $returnValue->getCommitId());
     $this->assertNotEquals($build->getStatus(), $returnValue->getStatus());
     $this->assertEquals(Build::STATUS_NEW, $returnValue->getStatus());
     $this->assertNull($returnValue->getLog());
     $this->assertEquals($build->getBranch(), $returnValue->getBranch());
     $this->assertNotEquals($build->getCreated(), $returnValue->getCreated());
     $this->assertNull($returnValue->getStarted());
     $this->assertNull($returnValue->getFinished());
     $this->assertEquals('test', $returnValue->getCommitMessage());
     $this->assertEquals('*****@*****.**', $returnValue->getCommitterEmail());
     $this->assertEquals($build->getExtra('item1'), $returnValue->getExtra('item1'));
 }
Esempio n. 2
0
 /**
  * Create a build using an existing build as a template:
  */
 public function rebuild($buildId)
 {
     $copy = BuildFactory::getBuildById($buildId);
     if (empty($copy)) {
         throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
     }
     $build = $this->buildService->createDuplicateBuild($copy);
     header('Location: ' . PHPCI_URL . 'build/view/' . $build->getId());
     exit;
 }
Esempio n. 3
0
 /**
  * Create a build using an existing build as a template:
  */
 public function rebuild($buildId)
 {
     $copy = BuildFactory::getBuildById($buildId);
     if (empty($copy)) {
         throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
     }
     $build = $this->buildService->createDuplicateBuild($copy);
     header('Location: ' . PHPCI_URL . 'build/view/' . $build->getId());
     exit;
 }
Esempio n. 4
0
 /**
  * Create a build using an existing build as a template:
  */
 public function rebuild($buildId)
 {
     $copy = BuildFactory::getBuildById($buildId);
     if (empty($copy)) {
         throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
     }
     $build = $this->buildService->createDuplicateBuild($copy);
     $response = new b8\Http\Response\RedirectResponse();
     $response->setHeader('Location', PHPCI_URL . 'build/view/' . $build->getId());
     return $response;
 }
Esempio n. 5
0
 /**
  * Loops through running.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new RunCommand($this->logger);
     $runner->setMaxBuilds(1);
     $runner->setDaemon(false);
     /** @var \PHPCI\Store\BuildStore $store */
     $store = Factory::getStore('Build');
     $service = new BuildService($store);
     $lastBuild = array_shift($store->getLatestBuilds(null, 1));
     $service->createDuplicateBuild($lastBuild);
     $runner->run(new ArgvInput(array()), $output);
 }