/**
  * @test
  */
 public function openResolvesAnUpperCaseSha1HashUsingTheResourceManager()
 {
     $sha1Hash = '68AC906495480A3404BEEE4874ED853A037A7A8F';
     $tempFile = tmpfile();
     $mockResource = $this->getMockBuilder(Resource::class)->disableOriginalConstructor()->getMock();
     $this->mockResourceManager->expects($this->once())->method('getResourceBySha1')->with($sha1Hash)->will($this->returnValue($mockResource));
     $this->mockResourceManager->expects($this->once())->method('getStreamByResource')->with($mockResource)->will($this->returnValue($tempFile));
     $openedPathAndFilename = '';
     $this->assertSame($tempFile, $this->resourceStreamWrapper->open('resource://' . $sha1Hash, 'r', 0, $openedPathAndFilename));
 }
 /**
  * @test
  */
 public function openResolvesAnUpperCaseSha1HashUsingTheResourceManager()
 {
     $sha1Hash = '68AC906495480A3404BEEE4874ED853A037A7A8F';
     $persistentResourcesStorageBaseUri = 'vfs://Foo/Some/';
     $absoluteResourcePath = $persistentResourcesStorageBaseUri . $sha1Hash;
     mkdir($persistentResourcesStorageBaseUri);
     file_put_contents('vfs://Foo/Some/' . $sha1Hash, 'fixture');
     $this->mockResourceManager->expects($this->once())->method('getPersistentResourcesStorageBaseUri')->will($this->returnValue($persistentResourcesStorageBaseUri));
     $openedPathAndFilename = '';
     $this->assertTrue($this->resourceStreamWrapper->open('resource://' . $sha1Hash, 'r', 0, $openedPathAndFilename));
     $this->assertSame($absoluteResourcePath, $openedPathAndFilename);
 }
 /**
  * @test
  */
 public function convertFromReturnsAnErrorIfTheUploadedFileCantBeImported()
 {
     $source = array('tmp_name' => 'SomeFilename', 'error' => \UPLOAD_ERR_OK);
     $this->mockResourceManager->expects($this->once())->method('importUploadedResource')->with($source)->will($this->returnValue(FALSE));
     $actualResult = $this->resourceTypeConverter->convertFrom($source, 'TYPO3\\Flow\\Resource\\Resource');
     $this->assertInstanceOf('TYPO3\\Flow\\Error\\Error', $actualResult);
 }
 /**
  * @test
  */
 public function convertFromReturnsAnErrorIfTheUploadedFileCantBeImported()
 {
     $this->inject($this->resourceTypeConverter, 'systemLogger', $this->createMock(\TYPO3\Flow\Log\SystemLoggerInterface::class));
     $source = array('tmp_name' => 'SomeFilename', 'error' => \UPLOAD_ERR_OK);
     $this->mockResourceManager->expects($this->once())->method('importUploadedResource')->with($source)->will($this->throwException(new \TYPO3\Flow\Resource\Exception()));
     $actualResult = $this->resourceTypeConverter->convertFrom($source, \TYPO3\Flow\Resource\Resource::class);
     $this->assertInstanceOf(\TYPO3\Flow\Error\Error::class, $actualResult);
 }