Merge pull request #157 from KennedyTedesco/builder-master

Added host() and port() to Builder
This commit is contained in:
Anton Medvedev 2015-02-15 13:48:44 +03:00
commit 721198f212
3 changed files with 41 additions and 1 deletions

View File

@ -43,6 +43,28 @@ class Builder
return $this;
}
/**
* Define server host
* @param int $host
* @return $this
*/
public function host($host)
{
$this->config->setHost($host);
return $this;
}
/**
* Define server port
* @param int $port
* @return $this
*/
public function port($port)
{
$this->config->setPort($port);
return $this;
}
/**
* If you use an ssh config file you can user it.
* @param string $file Config file path

View File

@ -31,7 +31,7 @@ use Symfony\Component\Console\Output\OutputInterface;
* @param int $port
* @return Builder
*/
function server($name, $domain, $port = 22)
function server($name, $domain = null, $port = 22)
{
$deployer = Deployer::get();

View File

@ -30,6 +30,24 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
$b->user('user', 'password');
}
public function testHostAndPort()
{
$config = $this->getMockBuilder('Deployer\Server\Configuration')->disableOriginalConstructor()->getMock();
$config->expects($this->once())
->method('setHost')
->with('localhost')
->will($this->returnSelf());
$config->expects($this->once())
->method('setPort')
->with(22)
->will($this->returnSelf());
$env = $this->getMock('Deployer\Server\Environment');
$b = new Builder($config, $env);
$b->host('localhost');
$b->port(22);
}
public function testConfig()
{
$config = $this->getMockBuilder('Deployer\Server\Configuration')->disableOriginalConstructor()->getMock();