public function testFilterProperties() { $profile = array('id' => 123, 'username' => 'bob', 'name' => null, 'email' => '', 'other_column' => 'myvalue', 'role' => Role::APP_ADMIN); $properties = array('external_id' => '456', 'username' => 'bobby', 'name' => 'Bobby', 'email' => 'admin@localhost', 'role' => ''); $expected = array('name' => 'Bobby', 'email' => 'admin@localhost'); $this->assertEquals($expected, UserProperty::filterProperties($profile, $properties)); }
/** * Update user profile * * @access public * @param array $profile * @param array $properties * @return array */ private function updateUser(array $profile, array $properties) { $values = UserProperty::filterProperties($profile, $properties); if (!empty($values)) { $values['id'] = $profile['id']; $result = $this->user->update($values); return $result ? array_merge($profile, $properties) : $profile; } return $profile; }
/** * Assign provider data to the local user * * @access public * @param integer $userId * @param UserProviderInterface $user * @return boolean */ public function assign($userId, UserProviderInterface $user) { $profile = $this->user->getById($userId); $values = UserProperty::filterProperties($profile, UserProperty::getProperties($user)); $values['id'] = $userId; if ($this->user->update($values)) { $profile = array_merge($profile, $values); $this->userSession->initialize($profile); return true; } return false; }