/**
  * @test
  */
 public function validatorBehavesCorrectlyOnDuplicateEntityWithSingleConfiguredIdentityProperty()
 {
     $validator = new \TYPO3\Flow\Validation\Validator\UniqueEntityValidator(array('identityProperties' => array('title')));
     $post = new Post();
     $post->setTitle('The title of the initial post');
     $this->postRepository->add($post);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $differentPost = new Post();
     $differentPost->setTitle('A different title');
     $this->assertFalse($validator->validate($differentPost)->hasErrors());
     $nextPost = new Post();
     $nextPost->setTitle('The title of the initial post');
     $this->assertTrue($validator->validate($nextPost)->hasErrors());
 }
 /**
  * @test
  */
 public function modificationsOnRetrievedEntitiesArePersistedIfUpdateHasBeenCalled()
 {
     $this->postRepository = $this->objectManager->get('TYPO3\\Flow\\Tests\\Functional\\Persistence\\Fixtures\\PostRepository');
     $post = new Post();
     $post->setTitle('Sample');
     $this->postRepository->add($post);
     $this->persistenceManager->persistAll();
     $post = $this->postRepository->findOneByTitle('Sample');
     $post->setTitle('Modified Sample');
     $this->postRepository->update($post);
     $this->persistenceManager->persistAll();
     $post = $this->postRepository->findOneByTitle('Modified Sample');
     $this->assertNotNull($post);
     $this->assertEquals('Modified Sample', $post->getTitle());
 }