/**
  * @test
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function setModelTypeResetsUuidPropertyNameAndIdentityPropertiesForValueObjects()
 {
     $classSchema = new \F3\FLOW3\Reflection\ClassSchema('SomeClass');
     $classSchema->setModelType(\F3\FLOW3\Reflection\ClassSchema::MODELTYPE_ENTITY);
     $classSchema->addProperty('foo', 'string');
     $classSchema->addProperty('bar', 'string');
     $classSchema->setUuidPropertyName('foo');
     $classSchema->markAsIdentityProperty('bar');
     $this->assertSame('foo', $classSchema->getUuidPropertyName());
     $this->assertSame(array('bar' => 'string'), $classSchema->getIdentityProperties());
     $classSchema->setModelType(\F3\FLOW3\Reflection\ClassSchema::MODELTYPE_VALUEOBJECT);
     $this->assertNull($classSchema->getUuidPropertyName());
     $this->assertSame(array(), $classSchema->getIdentityProperties());
 }
 /**
  * Builds class schemata from classes annotated as entities or value objects
  *
  * @param array $classNames
  * @return void
  * @author Robert Lemke <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  */
 protected function buildClassSchemata(array $classNames)
 {
     foreach ($classNames as $className) {
         $classSchema = new \F3\FLOW3\Reflection\ClassSchema($className);
         if ($this->isClassTaggedWith($className, 'entity')) {
             $classSchema->setModelType(\F3\FLOW3\Reflection\ClassSchema::MODELTYPE_ENTITY);
             $possibleRepositoryClassName = str_replace('\\Model\\', '\\Repository\\', $className) . 'Repository';
             if ($this->isClassReflected($possibleRepositoryClassName)) {
                 $classSchema->setAggregateRoot(TRUE);
             }
         } elseif ($this->isClassTaggedWith($className, 'valueobject')) {
             $classSchema->setModelType(\F3\FLOW3\Reflection\ClassSchema::MODELTYPE_VALUEOBJECT);
         }
         foreach ($this->getClassPropertyNames($className) as $propertyName) {
             if (!$this->isPropertyTaggedWith($className, $propertyName, 'transient') && $this->isPropertyTaggedWith($className, $propertyName, 'var')) {
                 $classSchema->addProperty($propertyName, implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')), $this->isPropertyTaggedWith($className, $propertyName, 'lazy'));
             }
             if ($this->isPropertyTaggedWith($className, $propertyName, 'uuid')) {
                 $classSchema->setUuidPropertyName($propertyName);
             }
             if ($this->isPropertyTaggedWith($className, $propertyName, 'identity')) {
                 $classSchema->markAsIdentityProperty($propertyName);
             }
         }
         $this->classSchemata[$className] = $classSchema;
     }
 }
 /**
  * @test
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function removeEntitiesByParentEmitsExpectedSql()
 {
     $fooBarClassSchema = new \F3\FLOW3\Reflection\ClassSchema('FooBar');
     $fooBarClassSchema->setModelType(\F3\FLOW3\Reflection\ClassSchema::MODELTYPE_ENTITY);
     $fooBarClassSchema->setAggregateRoot(TRUE);
     $quuxClassSchema = new \F3\FLOW3\Reflection\ClassSchema('Quux');
     $quuxClassSchema->setModelType(\F3\FLOW3\Reflection\ClassSchema::MODELTYPE_ENTITY);
     $mockStatement = $this->getMock('PDOStatement');
     $mockStatement->expects($this->once())->method('execute')->with(array('fakeUuid1'));
     $mockStatement->expects($this->once())->method('fetchAll')->will($this->onConsecutiveCalls(array(array('type' => 'FooBar', 'identifier' => 'heretostay'), array('type' => 'Quux', 'identifier' => 'goaway'))));
     $mockPdo = $this->getMock('PdoInterface');
     $mockPdo->expects($this->once())->method('prepare')->with('SELECT "identifier", "type" FROM "entities" WHERE "identifier" IN (SELECT DISTINCT "object" FROM "properties_data" WHERE "parent"=?)')->will($this->returnValue($mockStatement));
     $object1 = new \stdClass();
     $object2 = new \stdClass();
     $persistenceSession = new \F3\FLOW3\Persistence\Session();
     $persistenceSession->registerObject($object1, 'fakeUuid1');
     $persistenceSession->registerObject($object2, 'goaway');
     $backend = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\Persistence\\Backend\\GenericPdo\\Backend'), array('removeEntity', 'emitRemovedObject'));
     $backend->injectPersistenceSession($persistenceSession);
     $backend->expects($this->once())->method('removeEntity')->with($object2);
     $backend->_set('databaseHandle', $mockPdo);
     $backend->_set('classSchemata', array('FooBar' => $fooBarClassSchema, 'Quux' => $quuxClassSchema));
     $backend->_call('removeEntitiesByParent', $object1);
 }