/** * @param string $setting * @param UserInterface $user * @return string|null */ public function getValue($setting, UserInterface $user) { $userSetting = $this->mapper->getUserSetting($setting, $user); if ($userSetting) { return $userSetting->getValue(); } return null; }
/** * @dataProvider provideUserSetting */ public function testGetValue($userSetting) { $userMock = $this->getMock('ZfcUser\\Entity\\UserInterface'); $this->mapper->expects($this->once())->method('getUserSetting')->with('allow_email', $userMock)->willReturn($userSetting); if ($userSetting) { $userSetting->expects($this->once())->method('getValue')->willReturn('allow'); } $this->service->getValue('allow_email', $userMock); }