Exemplo n.º 1
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);
 }