/** * @covers Phansible\Renderer\VarfileRenderer::addMultipleVars */ public function testShouldAddMultipleVars() { $vars = ['region' => 'brazil', 'os' => 'debian']; $this->model->addMultipleVars($vars); $expected = ['variables' => Yaml::dump($vars), 'name' => 'common']; $this->assertEquals($expected, $this->model->getData()); }
public function indexAction(Request $request, Application $app) { $requestVars = $request->request->all(); $requestVars['server']['locale'] = $this->extractLocale($request->getLanguages()); $inventory = $this->getInventory($requestVars); $varsFile = new VarfileRenderer('all'); $playbook = new PlaybookRenderer(); // @todo fix str_replace $playbook->setVarsFilename(str_replace('ansible/', '', $varsFile->getFilePath())); $this->getVagrantBundle()->setPlaybook($playbook)->setVarsFile($varsFile)->setInventory($inventory); $app['roles']->setupRole($requestVars, $this->getVagrantBundle()); $playbook->addRole('app'); $zipPath = tempnam(sys_get_temp_dir(), "phansible_bundle_"); if ($this->getVagrantBundle()->generateBundle($zipPath, $playbook->getRoles())) { $vagrantfile = $this->getVagrantBundle()->getVagrantFile(); return $this->outputBundle($zipPath, $app, $vagrantfile->getName()); } return new Response('An error occurred.'); }
/** * @covers Phansible\Renderer\VarfileRenderer::renderFile */ public function testShouldRenderVarfile() { $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->setMethods(array('render'))->getMock(); $twig->expects($this->once())->method('render')->with($this->equalTo('vars.yml.twig'), $this->model->getData()); $result = $this->model->renderFile($twig); }