/** * @test * @author Karsten Dambekalns <*****@*****.**> */ public function uuidPropertyNameFromNewObjectIsUsedForRecord() { $className = 'SomeClass' . uniqid(); $fullClassName = 'F3\\FLOW3\\Persistence\\Tests\\' . $className; $identifier = \F3\FLOW3\Utility\Algorithms::generateUUID(); eval('namespace F3\\FLOW3\\Persistence\\Tests; class ' . $className . ' { public function FLOW3_Persistence_isNew() { return TRUE; } public function FLOW3_Persistence_isDirty($propertyName) { return FALSE; } public function FLOW3_Persistence_memorizeCleanState($propertyName = NULL) {} public function FLOW3_AOP_Proxy_getProxyTargetClassName() { return \'' . $fullClassName . '\'; } public function FLOW3_AOP_Proxy_getProperty($name) { if ($name === \'idProp\') return \'' . $identifier . '\'; } }'); $newObject = new $fullClassName(); $classSchema = new \F3\FLOW3\Reflection\ClassSchema($fullClassName); $classSchema->addProperty('idProp', 'string'); $classSchema->setUUIDPropertyName('idProp'); $mockStatement = $this->getMock('PDOStatement'); $mockStatement->expects($this->once())->method('execute')->with(array($identifier, $fullClassName)); $mockPdo = $this->getMock('PdoInterface'); $mockPdo->expects($this->once())->method('prepare')->with('INSERT INTO "entities" ("identifier", "type") VALUES (?, ?)')->will($this->returnValue($mockStatement)); $backend = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\Persistence\\Backend\\GenericPdo\\Backend'), array('dummy')); $backend->injectPersistenceSession(new \F3\FLOW3\Persistence\Session()); $backend->_set('databaseHandle', $mockPdo); $backend->_set('classSchemata', array($fullClassName => $classSchema)); $backend->_set('visitedDuringPersistence', new \SplObjectStorage()); $backend->_call('createObjectRecord', $newObject); }