App\Services\Deployment\DeployerServerListFileBuilder::setServer PHP Method

setServer() public method

Set a server model instance.
public setServer ( Model $server ) : App\Services\ServerList\DeployerServerListFileBuilder
$server Illuminate\Database\Eloquent\Model
return App\Services\ServerList\DeployerServerListFileBuilder $this
    public function setServer(Model $server)
    {
        $this->server = $server;
        return $this;
    }

Usage Example

    public function test_Should_OverrideAttributeInDeployerServerListFile_When_ProjectAttributeIsNotSpecified()
    {
        $path = vfsStream::url('rootDir/server.yml');
        $this->mockProjectAttributeEntity->shouldReceive('getDeployPath')->twice()->andReturn('/home/www/deploy2');
        $this->mockProjectModel->shouldReceive('getAttribute')->with('attributes')->andReturn($this->mockProjectAttributeEntity);
        $this->mockDeployerFile->shouldReceive('setBaseName')->once();
        $this->mockDeployerFile->shouldReceive('setFullPath')->once();
        $this->mockDeployerFile->shouldReceive('getFullPath')->andReturn($path);
        $serverListFileBuilder = new DeployerServerListFileBuilder(new LaravelFilesystem($this->app['files']), $this->mockDeployerFile, new Parser(), new Dumper());
        $this->mockServerModel->body = <<<EOF
test:
  host: localhost
  user: www
  identity_file:
    public_key: /path/to/public_key
    private_key: /path/to/private_key
  stage: testing
EOF;
        $serverListFileBuilder->setServer($this->mockServerModel)->setProject($this->mockProjectModel);
        $result = $serverListFileBuilder->pathInfo()->put()->getResult();
        $serverListFile = Yaml::parse(file_get_contents($path));
        $this->assertEquals('/home/www/deploy2', $serverListFile['test']['deploy_path']);
    }