public function it_generates_headers_using_generator(RequestInterface $request, StreamInterface $body, HeaderGenerator $headerGenerator) { $request->getBody()->willReturn($body); $headerGenerator->generate($request)->willReturn(['generated', 'headers']); $this->generate($request)->shouldHaveKeyWithValue(CURLOPT_HTTPHEADER, ['generated', 'headers']); }
/** * 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)]; }