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

pathInfo() public method

Set a server list file path info.
public pathInfo ( ) : App\Services\ServerList\DeployerServerListFileBuilder
return App\Services\ServerList\DeployerServerListFileBuilder $this
    public function pathInfo()
    {
        $id = md5(uniqid(rand(), true));
        $baseName = "server_{$id}.yml";
        $fullPath = storage_path("app/{$baseName}");
        $this->deployerFile->setBaseName($baseName);
        $this->deployerFile->setFullPath($fullPath);
        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']);
    }