/** * Test get password */ public function testGetPassword() { $this->askPasswordGetter->expects($this->once())->method('createQuestionHelper')->will($this->returnValue($this->questionHelper)); $this->questionHelper->expects($this->once())->method('ask')->with($this->input, $this->output, $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnCallback(function ($input, $output, Question $question) { // Check question $this->assertTrue($question->isHidden(), 'The question must be hidden'); $this->assertEquals('[user@host] Password:'******'some_password'; })); $realPassword = $this->askPasswordGetter->getPassword('host', 'user'); $this->assertEquals('some_password', $realPassword, 'Password not mismatch.'); }
/** * Create a lazy ask password getter with use context output and input interfaces * * @return CallablePasswordGetter */ public static function createLazyGetter() { return new CallablePasswordGetter(function ($host, $user) { $context = Context::get(); $output = $context->getOutput(); $input = $context->getInput(); $askPasswordGetter = new AskPasswordGetter($input, $output); return $askPasswordGetter->getPassword($host, $user); }); }