Esempio n. 1
0
 public function testCommitResultForSuccessFail()
 {
     // build is a fail
     $process = $this->getProcess();
     $process->expects($this->once())->method('isSuccessful')->will($this->returnValue(false));
     $process->expects($this->once())->method('getOutput')->will($this->returnValue('foo'));
     $process->expects($this->once())->method('getErrorOutput')->will($this->returnValue('bar'));
     // build is triggered as commit does not exist
     $builder = $this->getBuilder();
     $builder->expects($this->once())->method('prepare')->will($this->returnValue(array('sha1', 'fabien', '2011-01-01 01:01:01 +0200', 'initial commit')));
     $builder->expects($this->once())->method('build')->will($this->returnValue($process));
     // check commit status
     $commit = $this->getCommit();
     $commit->expects($this->once())->method('setStatusCode')->with($this->equalTo('failed'));
     $commit->expects($this->once())->method('setOutput')->with($this->matchesRegularExpression('/foo.*bar/s'));
     // check that storage is updated
     $storage = $this->getStorage();
     $storage->expects($this->any())->method('initCommit')->will($this->returnValue($commit));
     $storage->expects($this->once())->method('updateCommit')->with($this->equalTo($commit));
     $sismo = new Sismo($storage, $builder);
     $sismo->build($this->getProject());
 }
Esempio n. 2
0
File: app.php Progetto: havvg/Sismo
    if (is_file($app['config.storage.file'])) {
        $storage = (require $app['config.storage.file']);
    } else {
        $storage = new Storage($app['db']);
    }
    return $storage;
});
$app['builder'] = $app->share(function () use($app) {
    $process = new Process(sprintf('%s --version', $app['git.path']));
    if ($process->run() > 0) {
        throw new \RuntimeException(sprintf('The git binary cannot be found (%s).', $app['git.path']));
    }
    return new Builder($app['build.path'], $app['git.path'], $app['git.cmds']);
});
$app['sismo'] = $app->share(function () use($app) {
    $sismo = new Sismo($app['storage'], $app['builder']);
    if (!is_file($app['config.file'])) {
        throw new \RuntimeException(sprintf("Looks like you forgot to define your projects.\nSismo looked into \"%s\".", $app['config.file']));
    }
    $projects = (require $app['config.file']);
    if (null === $projects) {
        throw new \RuntimeException(sprintf('The "%s" configuration file must return an array of Projects (returns null).', $app['config.file']));
    }
    if (!is_array($projects)) {
        throw new \RuntimeException(sprintf('The "%s" configuration file must return an array of Projects (returns a non-array).', $app['config.file']));
    }
    foreach ($projects as $project) {
        if (!$project instanceof Project) {
            throw new \RuntimeException(sprintf('The "%s" configuration file must return an array of Project instances.', $app['config.file']));
        }
        $sismo->addProject($project);