backupUsersConfig = Configure::read('Users'); Router::scope('/', function ($routes) { $routes->fallbacks('InflectedRoute'); }); Router::plugin('Users', function ($routes) { $routes->fallbacks('InflectedRoute'); }); Router::scope('/auth', function ($routes) { $routes->connect( '/*', ['plugin' => 'Users', 'controller' => 'Users', 'action' => 'opauthInit'] ); }); Router::connect('/a/validate/*', [ 'admin' => false, 'plugin' => 'Users', 'controller' => 'SocialAccounts', 'action' => 'resendValidation' ]); Security::salt('YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); Configure::write('App.namespace', 'Users'); $this->request = $this->getMock('Cake\Network\Request', ['is', 'method']); $this->request->expects($this->any())->method('is')->will($this->returnValue(true)); $this->response = $this->getMock('Cake\Network\Response', ['stop']); $this->Controller = new Controller($this->request, $this->response); $this->Registry = $this->Controller->components(); $this->Controller->UsersAuth = new UsersAuthComponent($this->Registry); } /** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); $_SESSION = []; unset($this->Controller, $this->UsersAuth); Configure::write('Users', $this->backupUsersConfig); } /** * Test initialize * */ public function testInitialize() { $this->Registry->unload('Auth'); $this->Controller->UsersAuth = new UsersAuthComponent($this->Registry); $this->assertInstanceOf('Users\Controller\Component\UsersAuthComponent', $this->Controller->UsersAuth); } /** * Test initialize with not rememberMe component needed * */ public function testInitializeNoRequiredRememberMe() { Configure::write('Users.RememberMe.active', false); $class = 'Users\Controller\Component\UsersAuthComponent'; $this->Controller->UsersAuth = $this->getMockBuilder($class) ->setMethods(['_loadRememberMe', '_initAuth', '_loadSocialLogin', '_attachPermissionChecker']) ->disableOriginalConstructor() ->getMock(); $this->Controller->UsersAuth->expects($this->once()) ->method('_initAuth'); $this->Controller->UsersAuth->expects($this->once()) ->method('_loadSocialLogin'); $this->Controller->UsersAuth->expects($this->never()) ->method('_loadRememberMe'); $this->Controller->UsersAuth->initialize([]); } }