public function testSwitchProfile()
{
$profileManagerMock = $this->getMock('\\StackFormation\\Profile\\Manager', [], [], '', false);
$profileManagerMock->expects($this->exactly(2))->method('getStackFactory')->willReturnCallback(function ($profile) {
if ($profile == 'myprofile1') {
$stackFactoryMock = $this->getMock('\\StackFormation\\StackFactory', [], [], 'LocalStackFactory', false);
$stackFactoryMock->method('getStackOutput')->willReturn('dummyOutputLocal');
return $stackFactoryMock;
}
if ($profile == 'myprofile2') {
$subStackFactoryMock = $this->getMock('\\StackFormation\\StackFactory', [], [], 'RemoteStackFactory', false);
$subStackFactoryMock->method('getStackOutput')->willReturn('dummyOutputRemote');
return $subStackFactoryMock;
}
return null;
});
$config = new \StackFormation\Config([FIXTURE_ROOT . 'Config/blueprint.switch_profile.yml']);
$valueResolver = new \StackFormation\ValueResolver\ValueResolver(null, $profileManagerMock, $config);
$blueprintFactory = new \StackFormation\BlueprintFactory($config, $valueResolver);
$blueprint = $blueprintFactory->getBlueprint('switch_profile');
$parameters = $blueprint->getParameters(true);
$parameters = Div::flatten($parameters, 'ParameterKey', 'ParameterValue');
$this->assertEquals('Bar1', $parameters['Foo1']);
$this->assertEquals('dummyOutputRemote', $parameters['Foo2']);
$this->assertEquals('dummyOutputLocal', $parameters['Foo3']);
}