public function testConvertFieldsMagicMethod() { $displayName = 'foo'; $otherField = 500; $user = new stdClass(); $user->displayname = $displayName; $user->otherField = $otherField; $this->baseLdapUser->setUser($user); $this->baseLdapUser->setConvertFields(['name' => 'displayname']); // check that the magic method converted the property name correctly $this->assertEquals($displayName, $this->baseLdapUser->name); // check that the magic method also pulls without converting $this->assertEquals($displayName, $this->baseLdapUser->displayname); // check that the magic method grabbed the field from the user info $this->assertEquals($otherField, $this->baseLdapUser->otherField); }
/** * Bind the interfaces to their implementations in the service container. */ public function registerLdapInterfaces() { $this->app->bind('LaravelAuthLdap\\Contracts\\LdapServer', function ($app) { $server = new AdLDAPLdapServer(); $server->setAdServer(new adLDAP($app->config['adldap'])); return $server; }); $this->app->bind('LaravelAuthLdap\\Contracts\\LdapUser', function ($app) { $user = new BaseLdapUser(); $user->setConvertFields($app->config['auth-ldap.convert_fields']); $user->setUsernameField($app->config['auth-ldap.username_field']); return $user; }); $this->app->bind('LaravelAuthLdap\\Contracts\\LdapUserProvider', function ($app) { $provider = new BaseLdapUserProvider(); $driverName = array_get($app->config['auth-ldap'], 'provider.driver'); if ($driverName !== null) { $driver = $this->app['auth']->driver($driverName); $provider->setProvider($driver->getProvider()); } $provider->setLdapServer($app->make('LaravelAuthLdap\\Contracts\\LdapServer')); $mustExist = array_get($app->config['auth-ldap'], 'provider.must_exist'); $provider->setUserMustExistInProvider($mustExist === null ? false : $mustExist); $provider->setCredentialsFields($app->config['auth-ldap.credentials_fields']); return $provider; }); }