public function testCanGetUserName() { $this->setServiceLocator(Bootstrap::getServiceManager()); $username = "******"; $this->mockLogin($username); $this->assertEquals($username, $this->getUsername()); $this->assertEquals($username, $this->getUserSessionModel()->getName()); }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->AuthAdaptorMySQL = new AuthAdaptorMySQL(); $this->serviceManager = Bootstrap::getServiceManager(); $this->AuthAdaptorMySQL->setServiceLocator($this->serviceManager); $this->assertTrue($this->AuthAdaptorMySQL->getServiceLocator() == $this->serviceManager); Bootstrap::initDatabase(); }
public function testCanSaveAndLoadFeedback() { $feedback = Bootstrap::getServiceManager()->get('FeedbackModel')->init(); $feedback->setData(["email" => "*****@*****.**", "message" => "Test message"]); $feedbackSavedId = $feedback->create(); $sm = Bootstrap::getServiceManager(); $feedbackLoaded = $sm->get('FeedbackModel'); $feedbackLoaded->init($feedbackSavedId); $loadedId = $feedbackLoaded->getId(); $this->assertEquals($feedbackSavedId, $loadedId); }
public function testPasswordResetCode() { $serviceManager = Bootstrap::getServiceManager(); $userService = $serviceManager->get('Netsensia\\Service\\UserService'); $userIdFromEmail = $userService->getUserIdFromEmail('*****@*****.**'); $this->assertTrue(is_numeric($userIdFromEmail) && $userIdFromEmail > 0); $userModel = $serviceManager->get('UserModel'); $userModel->init($userIdFromEmail); $passwordResetCode = $userService->setNewPasswordResetCode($userModel); $this->assertEquals(32, strlen($passwordResetCode)); $userIdFromPasswordResetCode = $userService->getUserIdFromPasswordResetCode($passwordResetCode); $this->assertEquals($userIdFromEmail, $userIdFromPasswordResetCode); }
public function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => $this->controllerName)); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); $this->setApplicationConfig($serviceManager->get('ApplicationConfig')); parent::setUp(); }
public function setUp() { $this->model = new DatabaseTableModel(); $this->model->setServiceLocator(Bootstrap::getServiceManager()); $this->model->setData(['key1' => 'value1', 'key2' => 'value2']); }
public function testCanGetUserIdFromShortcutMethod() { $userModel = Bootstrap::getServiceManager()->get('UserModel')->init(); $userModel->setPrimaryKey(['userid' => 1]); $this->assertEquals(1, $userModel->getUserId()); }
public function testCanPostToUpdatePasswordForm() { $mockUserId = 1; $mockPassword = '******'; $mockEncryptedPassword = '******'; $mockPasswordResetCode = 'testpasswordcode'; $userService = $this->getMockBuilder('Netsensia\\Service\\UserService')->disableOriginalConstructor()->getMock(); $userService->expects($this->any())->method('getUserIdFromPasswordResetCode')->with($this->equalTo($mockPasswordResetCode))->will($this->returnValue($mockUserId)); $userService->expects($this->any())->method('encryptPassword')->with($this->equalTo($mockPassword))->will($this->returnValue($mockEncryptedPassword)); $userModel = $this->getMock('Netsensia\\Model\\User'); $userModel->expects($this->once())->method('init')->with($this->equalTo($mockUserId))->will($this->returnValue($userModel)); $map = array(array('passwordresetcode', 0, null), array('password', $mockEncryptedPassword, null)); $userModel->expects($this->exactly(2))->method('set')->will($this->returnValueMap($map)); $userModel->expects($this->once())->method('save'); $serviceLocator = Bootstrap::getServiceManager(); $serviceLocator->setService('Netsensia\\Service\\UserService', $userService); $serviceLocator->setService('UserModel', $userModel); $this->routeMatch->setParam('password-reset-code', $mockPasswordResetCode); $this->routeMatch->setParam('action', 'update-password'); $this->request->setMethod('POST'); $this->request->getPost()->set('password', 'testpassword'); $this->request->getPost()->set('confirmpassword', 'testpassword'); $this->controller->setServiceLocator($serviceLocator); $this->controller->dispatch($this->request); $response = $this->controller->getResponse(); $this->assertEquals(302, $response->getStatusCode()); }
public function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->locationService = $serviceManager->get('LocationService'); }