/** * @test */ public function openResolvesAnUpperCaseSha1HashUsingTheResourceManager() { $sha1Hash = '68AC906495480A3404BEEE4874ED853A037A7A8F'; $tempFile = tmpfile(); $mockResource = $this->getMockBuilder(PersistentResource::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->assertTrue($this->resourceStreamWrapper->open('resource://' . $sha1Hash, 'r', 0, $openedPathAndFilename)); $this->assertAttributeSame($tempFile, 'handle', $this->resourceStreamWrapper); }
/** * @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); }