Neos\Flow\Tests\Unit\Property\TypeConverter\PersistentObjectConverterTest::convertFromShouldCreateObjectWhenThereAreConstructorParameters PHP Method

convertFromShouldCreateObjectWhenThereAreConstructorParameters() public method

    public function convertFromShouldCreateObjectWhenThereAreConstructorParameters()
    {
        $source = ['propertyX' => 'bar'];
        $convertedChildProperties = ['property1' => 'param1', 'property2' => 'bar'];
        $expectedObject = new ClassWithSettersAndConstructor('param1');
        $expectedObject->setProperty2('bar');
        $this->mockReflectionService->expects($this->once())->method('hasMethod')->with(ClassWithSettersAndConstructor::class, '__construct')->will($this->returnValue(true));
        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with(ClassWithSettersAndConstructor::class, '__construct')->will($this->returnValue(['property1' => ['optional' => false]]));
        $this->mockObjectManager->expects($this->once())->method('getClassNameByObjectName')->with(ClassWithSettersAndConstructor::class)->will($this->returnValue(ClassWithSettersAndConstructor::class));
        $configuration = $this->buildConfiguration([PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => true]);
        $result = $this->converter->convertFrom($source, ClassWithSettersAndConstructor::class, $convertedChildProperties, $configuration);
        $this->assertEquals($expectedObject, $result);
        $this->assertEquals('bar', $expectedObject->getProperty2());
    }