public function it_creates_read_function_using_factory(RequestInterface $request, StreamInterface $body, ReadFunctionFactory $readFunctionFactory, ReadFunction $readFunction) { $request->getBody()->willReturn($body); $readFunctionFactory->create($body)->willReturn($readFunction); $this->generate($request)->shouldHaveKeyWithValue(CURLOPT_READFUNCTION, [$readFunction, 'read']); }
/** * Generates options to make multipart upload of given request * @param RequestInterface $request subject to options generation * @return array */ public function generate(RequestInterface $request) { $readFunction = $this->readFunctionFactory->create($request->getBody()); return [CURLOPT_UPLOAD => true, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_READFUNCTION => [$readFunction, 'read'], CURLOPT_HEADERFUNCTION => [$this->headerParser, 'parseFunction'], CURLOPT_HTTPHEADER => $this->headerGenerator->generate($request)]; }