/**
  * @test
  * @expectedException \TYPO3\Flow\Persistence\Exception\ObjectValidationFailedException
  */
 public function validationIsDoneForReconstitutedEntities()
 {
     $this->removeExampleEntities();
     $this->insertExampleEntity();
     $this->persistenceManager->persistAll();
     $firstResult = $this->testEntityRepository->findAll()->getFirst();
     $firstResult->setName('A');
     $this->testEntityRepository->update($firstResult);
     $this->persistenceManager->persistAll();
 }
 /**
  * @test
  */
 public function hasUnpersistedChangesReturnsTrueAfterObjectUpdate()
 {
     $this->removeExampleEntities();
     $this->insertExampleEntity();
     $this->persistenceManager->persistAll();
     /** @var TestEntity $testEntity */
     $testEntity = $this->testEntityRepository->findAll()->getFirst();
     $testEntity->setName('Another name');
     $this->testEntityRepository->update($testEntity);
     $this->assertTrue($this->persistenceManager->hasUnpersistedChanges());
 }
 /**
  * @test
  */
 public function doctrineEmbeddablesAreActuallyEmbedded()
 {
     /* @var $entityManager \Doctrine\Common\Persistence\ObjectManager */
     $entityManager = $this->objectManager->get('Doctrine\\Common\\Persistence\\ObjectManager');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $metaData = $entityManager->getClassMetadata('TYPO3\\Flow\\Tests\\Functional\\Persistence\\Fixtures\\TestEntity');
     $this->assertTrue($metaData->hasField('embedded.value'), 'ClassMetadata does not contain embedded value');
     $schema = $schemaTool->getSchemaFromMetadata(array($metaData));
     $this->assertTrue($schema->getTable('persistence_testentity')->hasColumn('embedded_value'), 'Database schema does not contain embedded value field');
     $embeddable = new TestEmbeddable('someValue');
     $testEntity = new TestEntity();
     $testEntity->setEmbedded($embeddable);
     $this->testEntityRepository->add($testEntity);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     /* @var $testEntity TestEntity */
     $testEntity = $this->testEntityRepository->findAll()->getFirst();
     $this->assertEquals('someValue', $testEntity->getEmbedded()->getValue());
 }