Update# testing: use returnCallback() to mock IConfig
This commit is contained in:
parent
3bb6bc8026
commit
3e9f594163
|
|
@ -200,27 +200,11 @@ class RegistrationServiceTest extends TestCase {
|
|||
//$reg->setPassword("asdf");
|
||||
$reg->setEmailConfirmed(true);
|
||||
|
||||
/*
|
||||
$map = [
|
||||
["registration", 'registered_user_group', 'none'],
|
||||
["registration", 'admin_approval_required', 'no']
|
||||
];
|
||||
*/
|
||||
|
||||
$this->config->expects($this->at(0))
|
||||
$this->config->expects($this->atLeastOnce())
|
||||
->method('getAppValue')
|
||||
->with("registration", 'registered_user_group', 'none')
|
||||
->willReturn('none');
|
||||
$this->config->expects($this->at(1))
|
||||
->method('getAppValue')
|
||||
->with("registration", 'admin_approval_required', 'no')
|
||||
->willReturn('no');
|
||||
->will($this->returnCallback(array($this, 'settingsCallback1')));
|
||||
|
||||
|
||||
//$regroup = $this->config->getAppValue("registration", 'registered_user_group', 'none');
|
||||
//print_r($regroup);
|
||||
//$this->assertEquals($this->config->getAppValue('registration', 'registered_user_group', 'none'), "none");
|
||||
|
||||
$form_input_username = 'alice1';
|
||||
$resulting_user = $this->service->createAccount($reg, $form_input_username, 'asdf');
|
||||
|
||||
|
|
@ -266,4 +250,13 @@ class RegistrationServiceTest extends TestCase {
|
|||
|
||||
$resulting_user = $this->service->createAccount($reg);
|
||||
}
|
||||
|
||||
public function settingsCallback1($app, $key, $default) {
|
||||
$map = [
|
||||
'registered_user_group' => 'none',
|
||||
'admin_approval_required' => 'no'
|
||||
];
|
||||
|
||||
return $map[$key];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue