/** * Register the service provider. * * @return void */ public function register() { $driver = $this->app['config']['auth.driver']; if ($driver === 'wordpress') { $this->app->bindShared('auth', function ($app) { // Once the authentication service has actually been requested by the developer // we will set a variable in the application indicating such. This helps us // know that we need to set any queued cookies in the after event later. $app['auth.loaded'] = true; $auth = new WpAuth($app); $auth->setDispatcher($app['events']); return $auth; }); } else { parent::register(); } }
/** * @test */ public function level_should_validate_against_user_levels() { $app['config']['auth.credentials.login'] = '******'; $app['config']['auth.credentials.password'] = '******'; $wpAuth = new WpAuth($app); $wpAuth->setUser(new \WP_User()); // level 10 $this->assertFalse($wpAuth->level(11)); $this->assertTrue($wpAuth->level(10)); $this->assertTrue($wpAuth->level(9)); $this->assertTrue($wpAuth->level(5)); $this->assertTrue($wpAuth->level(1)); $this->assertFalse($wpAuth->level(1, '=')); $this->assertFalse($wpAuth->level(5, '<')); $this->assertFalse($wpAuth->level(5, '<=')); $this->assertTrue($wpAuth->level(5, '>')); $this->assertTrue($wpAuth->level(5, '>=')); }