If the input format is an array, this method assumes the resource to be a
fresh file upload and imports the temporary upload file through the
ResourceManager.
Note that $source['error'] will also be present if a file was successfully
uploaded. In that case its value will be \UPLOAD_ERR_OK.
public convertFrom ( array $source, string $targetType, array $convertedChildProperties = [], Neos\Flow\Property\PropertyMappingConfigurationInterface $configuration = null ) : |
||
$source | array | The upload info (expected keys: error, name, tmp_name) |
$targetType | string | |
$convertedChildProperties | array | |
$configuration | Neos\Flow\Property\PropertyMappingConfigurationInterface | |
Результат | if the input format is not supported or could not be converted for other reasons |
/** * @test */ public function convertFromReturnsAnErrorIfTheUploadedFileCantBeImported() { $this->inject($this->resourceTypeConverter, 'systemLogger', $this->createMock(SystemLoggerInterface::class)); $source = ['tmp_name' => 'SomeFilename', 'error' => \UPLOAD_ERR_OK]; $this->mockResourceManager->expects($this->once())->method('importUploadedResource')->with($source)->will($this->throwException(new Exception())); $actualResult = $this->resourceTypeConverter->convertFrom($source, PersistentResource::class); $this->assertInstanceOf(FlowError\Error::class, $actualResult); }