mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 09:12:51 +01:00
Merge pull request #290 from ZeeCoder/feature/auto-server-env-vars
Refactored PR based on #272 (automatic setting of the "server" env var)
This commit is contained in:
commit
06c958f5c4
@ -27,6 +27,12 @@ class Builder
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->env = $env;
|
||||
|
||||
$env->setAsProtected('server', [
|
||||
'name' => $config->getName(),
|
||||
'host' => $config->getHost(),
|
||||
'port' => $config->getPort(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,11 +112,34 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$config = $this->getMockBuilder('Deployer\Server\Configuration')->disableOriginalConstructor()->getMock();
|
||||
$env = $this->getMock('Deployer\Server\Environment');
|
||||
$env->expects($this->once())
|
||||
|
||||
// Configuring stubs
|
||||
$config
|
||||
->method('getName')
|
||||
->will($this->returnValue('test-name'));
|
||||
$config
|
||||
->method('getHost')
|
||||
->will($this->returnValue('test-host'));
|
||||
$config
|
||||
->method('getPort')
|
||||
->will($this->returnValue(22));
|
||||
|
||||
// The Builder class should create the server env variable.
|
||||
$env->expects($this->at(0))
|
||||
->method('setAsProtected')
|
||||
->with('server', [
|
||||
'name' => 'test-name',
|
||||
'host' => 'test-host',
|
||||
'port' => 22,
|
||||
])
|
||||
->will($this->returnSelf());
|
||||
|
||||
// The `env` method of the Builder class should internally call the
|
||||
// Environment's `set` method.
|
||||
$env->expects($this->at(1))
|
||||
->method('set')
|
||||
->with('name', 'value')
|
||||
->will($this->returnSelf());
|
||||
|
||||
$b = new Builder($config, $env);
|
||||
$b->env('name', 'value');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user