mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/12684] Fix tests
PHPBB3-12684
This commit is contained in:
parent
637b02690d
commit
fe31060fca
2 changed files with 15 additions and 11 deletions
|
@ -125,7 +125,6 @@ class add extends \phpbb\console\command\command
|
||||||
$question->setValidator(function ($value) use ($self, $helper, $input, $output) {
|
$question->setValidator(function ($value) use ($self, $helper, $input, $output) {
|
||||||
$question = new Question($self->ask_user('CONFIRM_PASSWORD'));
|
$question = new Question($self->ask_user('CONFIRM_PASSWORD'));
|
||||||
$question->setHidden(true);
|
$question->setHidden(true);
|
||||||
$question->setHiddenFallback(false);
|
|
||||||
|
|
||||||
$confirm = $helper->ask($input, $output, $question);
|
$confirm = $helper->ask($input, $output, $question);
|
||||||
if ($confirm != $value)
|
if ($confirm != $value)
|
||||||
|
@ -135,7 +134,6 @@ class add extends \phpbb\console\command\command
|
||||||
return $value;
|
return $value;
|
||||||
});
|
});
|
||||||
$question->setHidden(true);
|
$question->setHidden(true);
|
||||||
$question->setHiddenFallback(false);
|
|
||||||
$question->setMaxAttempts(5);
|
$question->setMaxAttempts(5);
|
||||||
|
|
||||||
$data['new_password'] = $helper->ask($input, $output, $question);
|
$data['new_password'] = $helper->ask($input, $output, $question);
|
||||||
|
@ -223,7 +221,7 @@ class add extends \phpbb\console\command\command
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
throw new runtime_exception(implode("\n", array_map(array($this->user, 'lang'), $error)));
|
throw new runtime_exception(implode("\n", array_map(array($this->language, 'lang'), $error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,10 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $config;
|
protected $config;
|
||||||
protected $user;
|
protected $user;
|
||||||
|
protected $language;
|
||||||
protected $passwords_manager;
|
protected $passwords_manager;
|
||||||
protected $command_name;
|
protected $command_name;
|
||||||
protected $dialog;
|
protected $question;
|
||||||
protected $phpbb_root_path;
|
protected $phpbb_root_path;
|
||||||
protected $php_ext;
|
protected $php_ext;
|
||||||
|
|
||||||
|
@ -59,11 +60,16 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case
|
||||||
|
|
||||||
$db = $this->db = $this->new_dbal();
|
$db = $this->db = $this->new_dbal();
|
||||||
|
|
||||||
|
$this->language = $this->getMockBuilder('\phpbb\language\language')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$this->language->expects($this->any())
|
||||||
|
->method('lang')
|
||||||
|
->will($this->returnArgument(0));
|
||||||
$user = $this->user = $this->getMock('\phpbb\user', array(), array(
|
$user = $this->user = $this->getMock('\phpbb\user', array(), array(
|
||||||
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
|
$this->language,
|
||||||
'\phpbb\datetime')
|
'\phpbb\datetime'
|
||||||
);
|
));
|
||||||
$this->user->method('lang')->will($this->returnArgument(0));
|
|
||||||
|
|
||||||
$driver_helper = new \phpbb\passwords\driver\helper($this->config);
|
$driver_helper = new \phpbb\passwords\driver\helper($this->config);
|
||||||
$passwords_drivers = array(
|
$passwords_drivers = array(
|
||||||
|
@ -105,7 +111,7 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case
|
||||||
|
|
||||||
$this->assertEquals(2, $this->get_user_id('Admin'));
|
$this->assertEquals(2, $this->get_user_id('Admin'));
|
||||||
|
|
||||||
$this->dialog->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n"));
|
$this->question->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n"));
|
||||||
|
|
||||||
$command_tester->execute(array(
|
$command_tester->execute(array(
|
||||||
'command' => $this->command_name,
|
'command' => $this->command_name,
|
||||||
|
@ -137,11 +143,11 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case
|
||||||
public function get_command_tester()
|
public function get_command_tester()
|
||||||
{
|
{
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
$application->add(new add($this->user, $this->db, $this->config, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext));
|
$application->add(new add($this->user, $this->db, $this->config, $this->language, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext));
|
||||||
|
|
||||||
$command = $application->find('user:add');
|
$command = $application->find('user:add');
|
||||||
$this->command_name = $command->getName();
|
$this->command_name = $command->getName();
|
||||||
$this->dialog = $command->getHelper('dialog');
|
$this->question = $command->getHelper('question');
|
||||||
return new CommandTester($command);
|
return new CommandTester($command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue