diff options
author | Pellaeon Lin <nfsmwlin@gmail.com> | 2018-06-30 12:41:31 +0300 |
---|---|---|
committer | Pellaeon Lin <nfsmwlin@gmail.com> | 2018-06-30 12:41:31 +0300 |
commit | 3e9f594163f948680f50002b3c182f170e06864b (patch) | |
tree | d33a5da359ae44efd26f32e4e311a65117c3f672 /tests | |
parent | 3bb6bc802648bbdd028fd6e7a80c8b57d33ef1e3 (diff) |
Update# testing: use returnCallback() to mock IConfig
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/service/RegistrationServiceTest.php | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/tests/integration/service/RegistrationServiceTest.php b/tests/integration/service/RegistrationServiceTest.php index 9be5a25..59f04ba 100644 --- a/tests/integration/service/RegistrationServiceTest.php +++ b/tests/integration/service/RegistrationServiceTest.php @@ -200,26 +200,10 @@ 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)) - ->method('getAppValue') - ->with("registration", 'registered_user_group', 'none') - ->willReturn('none'); - $this->config->expects($this->at(1)) + $this->config->expects($this->atLeastOnce()) ->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]; + } } |