コード例 #1
0
 /**
  */
 public function testAction()
 {
     $queryName = uniqid('query');
     list($data, $expected) = $this->prepareDataAndExpected();
     $user = UserEntityProvider::createEntityWithRandomData();
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     $request->setQuery(new Parameters(array('q' => $queryName)));
     $this->authControllerPluginMock->expects($this->once())->method('__invoke')->with(null)->will($this->returnSelf());
     $this->authControllerPluginMock->expects($this->once())->method('getUser')->willReturn($user);
     $this->organizationRepoMock->expects($this->once())->method('getTypeAheadResults')->with($queryName, $user)->willReturn($data);
     /** @var JsonModel $result */
     $result = $this->controller->dispatch($request);
     $this->assertResponseStatusCode(Response::STATUS_CODE_200);
     $this->assertSame($expected, $result->getVariables());
 }
コード例 #2
0
 public function testIndexAction_WithGetRequest_WhenUnexpectedExceptionOccurred()
 {
     $userId = uniqid('user');
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     $this->routeMatch->setParam('userId', $userId);
     $this->serviceMock->expects($this->once())->method('proceed')->with($userId)->willThrowException(new \LogicException());
     $this->controller->dispatch($request);
     $this->assertResponseStatusCode(Response::STATUS_CODE_302);
     $this->assertRedirectTo('/en/auth/register');
     //$fm = $this->controller->flashMessenger();
     //$fm->setNamespace(Notification::NAMESPACE_DANGER);
     //$expectedMessages = array(
     //    'An unexpected error has occurred, please contact your system administrator'
     //);
     //$this->assertSame($expectedMessages, $fm->getCurrentMessages());
 }
コード例 #3
0
 public function testIndexAction_WithValidPostRequest()
 {
     $postData = array('name' => uniqid('name'), 'email' => uniqid('email') . '@' . uniqid('host') . '.com.pl');
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setPost(new Parameters($postData));
     $this->formMock->expects($this->once())->method('setData')->with($postData);
     $this->formMock->expects($this->once())->method('isValid')->willReturn(true);
     $registerInputFilter = new RegisterInputFilter();
     $registerInputFilter->add(array('name' => 'captcha'));
     $this->formMock->expects($this->once())->method('getInputFilter')->willReturn($registerInputFilter);
     $this->serviceMock->expects($this->once())->method('proceed');
     $result = $this->controller->dispatch($request);
     $expected = array('form' => $this->formMock);
     $this->assertResponseStatusCode(Response::STATUS_CODE_200);
     $this->assertSame($expected, $result);
     // TODO: reactivate
     //$fm = $this->controller->flashMessenger();
     //$fm->setNamespace(Notification::NAMESPACE_SUCCESS);
     //$expectedMessages = array(
     //    'An Email with an activation link has been sent, please try to check your email box'
     //);
     //$this->assertSame($expectedMessages, $fm->getCurrentMessages());
 }
コード例 #4
0
 public function testIndexAction_WithPostRequest()
 {
     $postData = array('identity' => uniqid('identity'));
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setPost(new Parameters($postData));
     $this->formMock->expects($this->once())->method('setData')->with($postData);
     $this->formMock->expects($this->once())->method('isValid')->willReturn(true);
     $this->formMock->expects($this->once())->method('getInputFilter')->willReturn(new ForgotPasswordInputFilter());
     $this->serviceMock->expects($this->once())->method('proceed');
     $result = $this->controller->dispatch($request);
     $expected = array('form' => $this->formMock);
     $this->assertResponseStatusCode(Response::STATUS_CODE_200);
     $this->assertSame($expected, $result);
     //$fm = $this->controller->flashMessenger();
     //$fm->setNamespace(Notification::NAMESPACE_SUCCESS);
     //$expectedMessages = array(
     //    'Mail with link for reset password has been sent, please try to check your email box'
     //);
     //$this->assertSame($expectedMessages, $fm->getCurrentMessages());
 }
コード例 #5
0
 public function testIndexAction_WithPostRequest()
 {
     $postData = array('valid data');
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setPost(new Parameters($postData));
     $userEntity = UserEntityProvider::createEntityWithRandomData();
     $this->authenticationServiceMock->expects($this->once())->method('getUser')->willReturn($userEntity);
     $this->formMock->expects($this->once())->method('bind')->with($userEntity);
     $this->formMock->expects($this->once())->method('setData')->with($postData);
     $this->formMock->expects($this->once())->method('isValid')->willReturn(true);
     $this->repositoriesMock->expects($this->once())->method('store')->with($userEntity);
     $result = $this->controller->dispatch($request);
     $expected = array('valid' => true, 'form' => $this->formMock);
     $this->assertResponseStatusCode(Response::STATUS_CODE_200);
     $this->assertSame($expected, $result);
 }