function testReadPassword()
 {
     if (!ReadlineConsole::isAvailable()) {
         $this->markTestSkipped('readline is not available.');
     }
     $script = __DIR__ . '/../../script/CLIFramework/IO/ReadlineConsoleReadPassword.php';
     $self = $this;
     $this->runScript($script, "test\n", function ($line) use($self) {
         $self->assertSame('test', $line);
     });
 }
 public function __construct()
 {
     $that = $this;
     $this['config.path'] = function ($c) {
         $filename = 'cliframework.ini';
         $configAtCurrentDirectory = getcwd() . DIRECTORY_SEPARATOR . $filename;
         $configAtHomeDirectory = getenv('HOME') . DIRECTORY_SEPARATOR . $filename;
         if (file_exists($configAtCurrentDirectory)) {
             return $configAtCurrentDirectory;
         }
         if (file_exists($configAtHomeDirectory)) {
             return $configAtHomeDirectory;
         }
         return null;
     };
     $this['event'] = function () {
         return new PhpEvent();
     };
     $this['config'] = function ($c) {
         if (empty($c['config.path']) || !$c['config.path']) {
             return new GlobalConfig(array());
         }
         return new GlobalConfig(parse_ini_file($c['config.path'], true));
     };
     $this['writer'] = function ($c) {
         // return new StreamWriter(STDOUT);
         $output = fopen("php://output", "w");
         return new StreamWriter($output);
     };
     $this['logger'] = function ($c) use($that) {
         return new Logger($that);
     };
     $this['formatter'] = function ($c) {
         return new Formatter();
     };
     $this['console.stty'] = function ($c) use($that) {
         if ($that->isWindows()) {
             // TODO support Windows
             return new NullStty();
         }
         return new UnixStty();
     };
     $this['console'] = function ($c) {
         if (ReadlineConsole::isAvailable()) {
             return new ReadlineConsole($c['console.stty']);
         }
         return new StandardConsole($c['console.stty']);
     };
     $this['command_loader'] = function ($c) {
         return CommandLoader::getInstance();
     };
     parent::__construct();
 }