public function canonicalize($string) { if (extension_loaded('mbstring')) { return parent::canonicalize($string); } else { return strtolower($string); } }
protected function migrate(&$user) { if (array_key_exists('isActive', $user)) { $user['enabled'] = (bool) $user['isActive']; unset($user['isActive']); } if (!array_key_exists('roles', $user)) { $user['roles'] = array(); } if (isset($user['confirmationToken'])) { unset($user['confirmationToken']); } if (isset($user['usernameLower'])) { $canonicalizer = new Canonicalizer(); $user['usernameCanonical'] = $canonicalizer->canonicalize($user['usernameLower']); $user['emailCanonical'] = $canonicalizer->canonicalize($user['email']); unset($user['usernameLower']); } if (isset($user['isSuperAdmin'])) { unset($user['isSuperAdmin']); $user['roles'] = array(User::ROLE_SUPER_ADMIN); } }
/** * @dataProvider canonicalizeProvider */ public function testCanonicalize($source, $expectedResult) { $canonicalizer = new Canonicalizer(); $this->assertSame($expectedResult, $canonicalizer->canonicalize($source)); }