Skip to content

Commit fe31060

Browse files
committed
[ticket/12684] Fix tests
PHPBB3-12684
1 parent 637b026 commit fe31060

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

phpBB/phpbb/console/command/user/add.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
125125
$question->setValidator(function ($value) use ($self, $helper, $input, $output) {
126126
$question = new Question($self->ask_user('CONFIRM_PASSWORD'));
127127
$question->setHidden(true);
128-
$question->setHiddenFallback(false);
129128

130129
$confirm = $helper->ask($input, $output, $question);
131130
if ($confirm != $value)
@@ -135,7 +134,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
135134
return $value;
136135
});
137136
$question->setHidden(true);
138-
$question->setHiddenFallback(false);
139137
$question->setMaxAttempts(5);
140138

141139
$data['new_password'] = $helper->ask($input, $output, $question);
@@ -223,7 +221,7 @@ protected function validate_user_data($data)
223221

224222
if ($error)
225223
{
226-
throw new runtime_exception(implode("\n", array_map(array($this->user, 'lang'), $error)));
224+
throw new runtime_exception(implode("\n", array_map(array($this->language, 'lang'), $error)));
227225
}
228226
}
229227

tests/console/user/add_test.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case
2424
protected $db;
2525
protected $config;
2626
protected $user;
27+
protected $language;
2728
protected $passwords_manager;
2829
protected $command_name;
29-
protected $dialog;
30+
protected $question;
3031
protected $phpbb_root_path;
3132
protected $php_ext;
3233

@@ -59,11 +60,16 @@ public function setUp()
5960

6061
$db = $this->db = $this->new_dbal();
6162

63+
$this->language = $this->getMockBuilder('\phpbb\language\language')
64+
->disableOriginalConstructor()
65+
->getMock();
66+
$this->language->expects($this->any())
67+
->method('lang')
68+
->will($this->returnArgument(0));
6269
$user = $this->user = $this->getMock('\phpbb\user', array(), array(
63-
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
64-
'\phpbb\datetime')
65-
);
66-
$this->user->method('lang')->will($this->returnArgument(0));
70+
$this->language,
71+
'\phpbb\datetime'
72+
));
6773

6874
$driver_helper = new \phpbb\passwords\driver\helper($this->config);
6975
$passwords_drivers = array(
@@ -105,7 +111,7 @@ public function test_add_dialog()
105111

106112
$this->assertEquals(2, $this->get_user_id('Admin'));
107113

108-
$this->dialog->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n"));
114+
$this->question->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n"));
109115

110116
$command_tester->execute(array(
111117
'command' => $this->command_name,
@@ -137,11 +143,11 @@ public function test_add_no_dialog_invalid()
137143
public function get_command_tester()
138144
{
139145
$application = new Application();
140-
$application->add(new add($this->user, $this->db, $this->config, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext));
146+
$application->add(new add($this->user, $this->db, $this->config, $this->language, $this->passwords_manager, $this->phpbb_root_path, $this->php_ext));
141147

142148
$command = $application->find('user:add');
143149
$this->command_name = $command->getName();
144-
$this->dialog = $command->getHelper('dialog');
150+
$this->question = $command->getHelper('question');
145151
return new CommandTester($command);
146152
}
147153

0 commit comments

Comments
 (0)