App\Services\Api\JsonRpc::deploy PHP Méthode

deploy() public méthode

Deploy a project.
public deploy ( integer $project_id ) : Deployment
$project_id integer
Résultat app\models\Deployment
    public function deploy($project_id)
    {
        $input = ['status' => null, 'message' => null, 'project_id' => $project_id, 'user_id' => Auth::guard('api')->user()->id, 'task' => 'deploy'];
        if ($this->deploymentForm->save($input)) {
            $project = $this->project->byId($project_id);
            $deployment = $project->getLastDeployment();
            return $deployment;
        } else {
            throw new InvalidArgumentException($this->deploymentForm->errors());
        }
    }

Usage Example

Exemple #1
0
 public function test_Should_NotThrowWException_When_RollbackProcedureSucceeds()
 {
     try {
         $this->mockAuthGuard->shouldReceive('user')->andReturn(new App\Models\User());
         Auth::shouldReceive('guard')->andReturn($this->mockAuthGuard);
         $this->mockDeploymentForm->shouldReceive('save')->once()->andReturn(true);
         $this->mockProjectModel->shouldReceive('getLastDeployment');
         $this->mockProjectRepository->shouldReceive('byId')->andReturn($this->mockProjectModel);
         $jsonRpc = new JsonRpc($this->mockProjectRepository, $this->mockDeploymentForm);
         $jsonRpc->deploy(1);
         $this->assertTrue(true);
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }