Neos\Flow\Tests\Unit\ObjectManagement\ObjectSerializerTest::serializeObjectAsPropertyArraySerializesArrayObjectPropertiesCorrectly PHP Method

serializeObjectAsPropertyArraySerializesArrayObjectPropertiesCorrectly() public method

    public function serializeObjectAsPropertyArraySerializesArrayObjectPropertiesCorrectly()
    {
        $className = 'DummyClass' . md5(uniqid(mt_rand(), true));
        eval('class ' . $className . ' {
			private $arrayObjectProperty;

			public function __construct() {
				$this->arrayObjectProperty = new \\ArrayObject(array(1,2,3));
			}
		}');
        $mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock();
        $mockReflectionService->expects($this->any())->method('getClassPropertyNames')->with($className)->will($this->returnValue(['arrayObjectProperty']));
        $objectSerializer = $this->getMockBuilder(ObjectSerializer::class)->disableOriginalConstructor()->setMethods(['buildStorageArrayForArrayProperty'])->getMock();
        $objectSerializer->injectReflectionService($mockReflectionService);
        $objectSerializer->expects($this->once())->method('buildStorageArrayForArrayProperty')->with([1, 2, 3])->will($this->returnValue('storable array'));
        $someObject = new $className();
        $expectedPropertyArray = [\spl_object_hash($someObject) => [ObjectSerializer::CLASSNAME => $className, ObjectSerializer::PROPERTIES => ['arrayObjectProperty' => [ObjectSerializer::TYPE => 'ArrayObject', ObjectSerializer::VALUE => 'storable array']]]];
        $this->assertEquals($expectedPropertyArray, $objectSerializer->serializeObjectAsPropertyArray($someObject), 'The ArrayObject property was not serialized correctly.');
    }
ObjectSerializerTest