protected function setUp() { $this->container = new Container(); ModuleFacade::clearResolvedInstances(); ModuleFacade::setContainer($this->container); $module = new \Altax\Module\Env\EnvModule($this->container); $this->container->addModule(Env::getModuleName(), $module); }
protected function execute(InputInterface $input, OutputInterface $output) { $table = $this->getHelperSet()->get('table'); $table->setHeaders(array('key', 'value')); $vars = Env::getVars(); foreach ($vars as $key => $value) { $table->addRow(array($key, $value)); } $table->render($output); }
public function nodesFromSSHConfigHosts($paths = array()) { $configPaths = array(); if (is_string($paths)) { $configPaths[] = $paths; } else { $configPaths = $paths; } if (sizeof($configPaths) < 1) { $configPaths = array("/etc/ssh_config", "/etc/ssh/ssh_config", Env::get("homedir") . "/.ssh/config"); } $nodesOptions = SSHConfig::parseToNodeOptionsFromFiles($configPaths); foreach ($nodesOptions as $key => $option) { $this->node($key, $option); } }
protected function setUp() { $this->container = new Container(); ModuleFacade::clearResolvedInstances(); ModuleFacade::setContainer($this->container); $this->container->addModule(\Altax\Module\Server\Facade\Server::getModuleName(), new \Altax\Module\Server\ServerModule($this->container)); $this->container->addModule(\Altax\Module\Task\Facade\Task::getModuleName(), new \Altax\Module\Task\TaskModule($this->container)); $this->container->addModule(\Altax\Module\Env\Facade\Env::getModuleName(), new \Altax\Module\Env\EnvModule($this->container)); Server::node("127.0.0.1", "test"); Server::node("localhost", "test"); Server::node("nodeIsSameNameOfRole", "nodeIsSameNameOfRole"); $this->task = new DefinedTask(); $this->task->setName("test_process_run"); $this->input = new ArgvInput(); $this->bufOutput = new BufferedOutput(); $this->runtimeTask = new RuntimeTask(null, $this->task, $this->input, $this->bufOutput); }
public function testRunLocally1() { $this->runtimeTask->getOutput()->setVerbosity(3); $homedir = Env::get("homedir"); $node = new Node(); $node->setName("127.0.0.1"); $process = new Process($this->runtimeTask, $node); $process->runLocally("echo helloworld", array("cwd" => $homedir)); $output = $process->getRuntimeTask()->getOutput()->fetch(); $this->assertRegExp("/helloworld/", $output); $os = php_uname('s'); if (preg_match('/Windows/i', $os)) { $regexp = '/Real command: cmd.exe \\/C "cd ' . preg_quote($homedir, '/') . ' & echo helloworld"/'; } else { $regexp = '/Real command: bash -l -c "cd ' . preg_quote($homedir, '/') . ' && echo helloworld"/'; } $this->assertRegExp($regexp, $output); }
public function testReplaceTilda() { $node = new Node(); Env::set("homedir", "/home/your"); $node->setKey("~/path/to/private_key"); $this->assertEquals("~/path/to/private_key", $node->getKey()); $this->assertEquals("/home/your/path/to/private_key", $node->getKeyOrDefault()); $node->setKey("~user/path/to/private_key"); $this->assertEquals("~user/path/to/private_key", $node->getKey()); $this->assertEquals("~user/path/to/private_key", $node->getKeyOrDefault()); $node->setKey("~"); $this->assertEquals("~", $node->getKey()); $this->assertEquals("/home/your", $node->getKeyOrDefault()); Env::set("homedir", "/home/your\\0"); $node->setKey("~/path/to/private_key"); $this->assertEquals("~/path/to/private_key", $node->getKey()); $this->assertEquals("/home/your\\0/path/to/private_key", $node->getKeyOrDefault()); $node->setKey("/path/to/private_key~"); $this->assertEquals("/path/to/private_key~", $node->getKey()); $this->assertEquals("/path/to/private_key~", $node->getKeyOrDefault()); }
public function getDefaultUsername() { return $this->defaultUsername ? $this->defaultUsername : Env::get("server.username"); }
public function testSetAndGet() { Env::set("aaa", "bbb"); $this->assertEquals("bbb", Env::get("aaa")); }