private function uploadFile(File $file) { $file->setName($this->getUniqueFileName($file->getPath(), $file->getName())); if (!$this->fileSystem->writeStream($file->getUuid()->toString(), $file->getStream())) { throw new \RuntimeException('Failed to process uploaded file.'); } $file->setStream($this->getFileStream($file->getUuid())); }
public function it_can_execute_a_request(RequestInterface $request, File $file) { $path = '/path/to/a/file.ext'; $filename = 'path.deux'; $request->offsetGet('path')->willReturn($path); $request->offsetGet('filename')->willReturn($filename); $request->getAcceptContentType()->willReturn('*/*'); $file->setName(FileNameValue::get($filename))->shouldBeCalled(); $this->fileRepository->getByFullPath($path)->willReturn($file); $this->fileRepository->updateMetaData($file)->shouldBeCalled(); $response = $this->executeRequest($request); $response->shouldHaveType(ResponseInterface::class); $response->getResponseName()->shouldReturn(RenameFileHandler::MESSAGE); $response['data']->shouldBe($file); }