public function testDefault()
 {
     $application = new Application($this->container);
     $application->setAutoExit(false);
     $application->add(new InitCommand());
     $command = $application->find("init");
     $testTmpConfigPath = __DIR__ . "/../../../tmp/Altax/Command/Builtin/InitCommandTest/.altax/config.php";
     @mkdir(dirname(dirname($testTmpConfigPath)), 0777, true);
     @unlink($testTmpConfigPath);
     @unlink(dirname($testTmpConfigPath) . "/composer.json");
     $orgDir = getcwd();
     chdir(dirname(dirname($testTmpConfigPath)));
     $commandTester = new CommandTester($command);
     $commandTester->execute(array("command" => $command->getName()));
     // Only checks to exist files. Don't inspect content of files.
     $this->assertEquals(true, is_file($testTmpConfigPath));
     $this->assertEquals(true, is_file(dirname($testTmpConfigPath) . "/composer.json"));
     // One more test. When files exits. it echo skip message.
     $commandTester = new CommandTester($command);
     $commandTester->execute(array("command" => $command->getName()));
     $this->assertRegExp("/Skiped creation process/", $commandTester->getDisplay());
     unlink($testTmpConfigPath);
     unlink(dirname($testTmpConfigPath) . "/composer.json");
     chdir($orgDir);
 }
    public function testDefault()
    {
        $application = new Application($this->container);
        $application->setAutoExit(false);
        $application->add(new RequireCommand());
        $command = $application->find("require");
        $testTmpConfigDir = __DIR__ . "/../../../tmp/Altax/Command/Builtin/RequireCommandTest/.altax";
        @mkdir($testTmpConfigDir, 0777, true);
        @copy(__DIR__ . "/RequireCommandTest/.altax/composer.json", $testTmpConfigDir . "/composer.json");
        $orgDir = getcwd();
        chdir(dirname($testTmpConfigDir));
        $commandTester = new CommandTester($command);
        $commandTester->execute(array("command" => $command->getName(), "packages" => array("foo/bar:1.0.0"), "--no-update" => true));
        $composerJson = file_get_contents($testTmpConfigDir . "/composer.json");
        $expected = <<<EOL
{
    "require": {
        "foo/bar": "1.0.0"
    }
}

EOL;
        $this->assertSame($expected, $composerJson);
        chdir($orgDir);
        @unlink($testTmpConfigDir . "/composer.json");
    }
Exemple #3
0
 public function testOverrideDescription()
 {
     $container = new Container();
     $task = new DefinedTask();
     $task->setName("test");
     $task->setDescription("custom description");
     $application = new Application($container);
     $application->setAutoExit(false);
     $application->add(new TestCommand($task));
     $command = $application->find("test");
     $this->assertEquals("custom description", $command->getDescription());
 }
 public function testDefault()
 {
     $application = new Application($this->container);
     $application->setAutoExit(false);
     $application->add(new EnvCommand());
     $command = $application->find("env");
     $commandTester = new CommandTester($command);
     $commandTester->execute(array("command" => $command->getName()));
     /*
     $expected = <<<EOL
     EOL;
     $this->assertEquals($expected, $commandTester->getDisplay());
     */
 }
 public function testDefault()
 {
     $container = new Container();
     $task = new DefinedTask();
     $task->setName("test");
     $task->setDescription("Description of the test task");
     $task->setClosure(function ($task) {
         $task->getOutput()->write("test message for closure task command");
     });
     $application = new Application($container);
     $application->setAutoExit(false);
     $application->add(new ClosureTaskCommand($task));
     $command = $application->find("test");
     $commandTester = new CommandTester($command);
     $commandTester->execute(array("command" => $command->getName()));
     $this->assertEquals("test message for closure task command", $commandTester->getDisplay());
 }
 public function testDefault()
 {
     $container = new Container();
     $task = new DefinedTask();
     $task->setName("test001");
     $application = new Application($container);
     $application->setAutoExit(false);
     $application->add(new ServerCommand($task));
     $command = $application->find("test");
     $commandTester = new CommandTester($command);
     // Don't test. This command blocks function. Don't return.
     /*        
     $commandTester->execute(
         array("command" => $command->getName())
         );
     echo $commandTester->getDisplay();
     */
 }
    public function testDefault()
    {
        $application = new Application($this->container);
        $application->setAutoExit(false);
        $application->add(new RolesCommand());
        $command = $application->find("roles");
        Server::node("web1.example.com", "web");
        Server::node("web2.example.com", "web");
        Server::node("db1.example.com", "db");
        $commandTester = new CommandTester($command);
        $commandTester->execute(array("command" => $command->getName()));
        $expected = <<<EOL
+------+------------------------------------+
| name | nodes                              |
+------+------------------------------------+
| web  | web1.example.com, web2.example.com |
| db   | db1.example.com                    |
+------+------------------------------------+

EOL;
        $this->assertEquals($expected, $commandTester->getDisplay(true));
    }
    public function testDetailOutput()
    {
        $application = new Application($this->container);
        $application->setAutoExit(false);
        $application->add(new NodesCommand());
        $command = $application->find("nodes");
        Server::node("web1.example.com");
        Server::node("web2.example.com");
        Server::node("web3.example.com");
        $commandTester = new CommandTester($command);
        $commandTester->execute(array("command" => $command->getName(), "--detail" => true));
        $expected = <<<EOL
+------------------+------+------+----------+-----+-------+
| name             | host | port | username | key | roles |
+------------------+------+------+----------+-----+-------+
| web1.example.com |      |      |          |     |       |
| web2.example.com |      |      |          |     |       |
| web3.example.com |      |      |          |     |       |
+------------------+------+------+----------+-----+-------+

EOL;
        $this->assertEquals($expected, $commandTester->getDisplay(true));
    }
    public function testDefault()
    {
        $application = new Application($this->container);
        $application->setAutoExit(false);
        $application->add(new InstallCommand());
        $command = $application->find("install");
        $testTmpConfigDir = __DIR__ . "/../../../tmp/Altax/Command/Builtin/InstallCommandTest/.altax";
        @mkdir($testTmpConfigDir, 0777, true);
        @copy(__DIR__ . "/InstallCommandTest/.altax/composer.json", $testTmpConfigDir . "/composer.json");
        $orgDir = getcwd();
        chdir(dirname($testTmpConfigDir));
        $commandTester = new CommandTester($command);
        $commandTester->execute(array("command" => $command->getName(), "--dry-run" => true));
        $expected = <<<EOL
Loading composer repositories with package information
Installing dependencies (including require-dev)
Nothing to install or update

EOL;
        $this->assertSame($expected, $commandTester->getDisplay(true));
        chdir($orgDir);
        @unlink($testTmpConfigDir . "/composer.json");
    }