/**
  * @covers ::getAttachedEntity()
  */
 public function testGetAttachedEntityWithExistentKeyWithExistingEntityInRepository()
 {
     $id = 'someId';
     $entity = $this->getEntity($id);
     $key = 'someKey';
     $className = get_class($entity);
     $this->attachableEntityManager->addAttachedEntity($entity, $key);
     $this->assertArrayHasKey($key, $this->references);
     $repository = $this->getMockBuilder(Repository::class)->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('find')->with($this->equalTo($id))->willReturn($entity);
     $this->repositories->expects($this->once())->method('getRepository')->with($this->equalTo($className))->willReturn($repository);
     $this->assertSame($entity, $this->attachableEntityManager->getAttachedEntity($key));
     $this->assertArrayHasKey($key, $this->references);
 }
 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);
 }