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

convertFromShouldCreateObjectWhenThereAreOptionalConstructorParameters() public method

    public function convertFromShouldCreateObjectWhenThereAreOptionalConstructorParameters()
    {
        $source = ['propertyX' => 'bar'];
        $expectedObject = new ClassWithSettersAndConstructor('thisIsTheDefaultValue');
        $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' => true, 'defaultValue' => 'thisIsTheDefaultValue']]));
        $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, [], $configuration);
        $this->assertEquals($expectedObject, $result);
    }