public function serializeObjectAsPropertyArraySerializessOnlyTheUuidOfPersistenceValueobjectsIfTheyAreNotMarkedAsNew()
{
$sessionClassName = 'dummyClass' . md5(uniqid(mt_rand(), true));
eval('class ' . $sessionClassName . ' {
public $entityProperty;
}');
$entityClassName = 'entityClass' . md5(uniqid(mt_rand(), true));
eval('class ' . $entityClassName . ' implements \\' . \Neos\Flow\ObjectManagement\Proxy\ProxyInterface::class . ' {
public function Flow_Aop_Proxy_invokeJoinPoint(\\' . \Neos\Flow\Aop\JoinPointInterface::class . ' $joinPoint) {}
public function __clone() {}
public function __wakeup() {}
}');
$entityObject = new $entityClassName();
$mockPersistenceManager = $this->createMock(PersistenceManagerInterface::class);
$mockPersistenceManager->expects($this->once())->method('isNewObject')->with($entityObject)->will($this->returnValue(false));
$mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($entityObject)->will($this->returnValue('someUUID'));
$mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock();
$mockReflectionService->expects($this->any())->method('getClassPropertyNames')->with($sessionClassName)->will($this->returnValue(['entityProperty']));
$mockReflectionService->expects($this->at(2))->method('isClassAnnotatedWith')->with($entityClassName, \Neos\Flow\Annotations\Entity::class)->will($this->returnValue(false));
$mockReflectionService->expects($this->at(3))->method('isClassAnnotatedWith')->with($entityClassName, \Neos\Flow\Annotations\ValueObject::class)->will($this->returnValue(true));
/** @var ObjectSerializer $objectSerializer */
$objectSerializer = $this->getMockBuilder(ObjectSerializer::class)->disableOriginalConstructor()->setMethods(['dummy'])->getMock();
$objectSerializer->injectReflectionService($mockReflectionService);
$objectSerializer->injectPersistenceManager($mockPersistenceManager);
$expectedArray = [ObjectSerializer::CLASSNAME => $sessionClassName, ObjectSerializer::PROPERTIES => ['entityProperty' => [ObjectSerializer::TYPE => 'persistenceObject', ObjectSerializer::VALUE => $entityClassName . ':someUUID']]];
$sessionObject = new $sessionClassName();
$sessionObject->entityProperty = $entityObject;
$objectsAsArray = $objectSerializer->serializeObjectAsPropertyArray($sessionObject);
$this->assertEquals($expectedArray, $objectsAsArray[spl_object_hash($sessionObject)]);
}