Ejemplo n.º 1
0
 public function testToHttpRequestWithFile()
 {
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setFileUpload(__FILE__);
     $endpoint = new Endpoint();
     $endpoint->setTimeout(10);
     $httpRequest = $this->adapter->toHttpRequest($request, $endpoint);
     $this->assertEquals(array(array('name' => 'content', 'type' => 'application/octet-stream; charset=binary', 'file' => __FILE__)), $httpRequest->getPostFiles());
 }
Ejemplo n.º 2
0
 public function testExecuteWithFileUpload()
 {
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setFileUpload(__FILE__);
     $endpoint = new Endpoint();
     $response = new \Zend_Http_Response(200, array('status' => 'HTTP 1.1 200 OK'), 'dummy');
     $mock = $this->getMock('Zend_Http_Client');
     $mock->expects($this->once())->method('setFileUpload')->with($this->equalTo('content'), $this->equalTo('content'), $this->equalTo(file_get_contents(__FILE__)), $this->equalTo('application/octet-stream; charset=binary'));
     $mock->expects($this->once())->method('request')->will($this->returnValue($response));
     $this->adapter->setZendHttp($mock);
     $this->adapter->execute($request, $endpoint);
 }
Ejemplo n.º 3
0
 public function testCreateContextPostFileRequest()
 {
     $timeout = 13;
     $method = Request::METHOD_POST;
     $data = 'test123';
     $request = new Request();
     $request->setMethod($method);
     $request->setFileUpload(__FILE__);
     $endpoint = new Endpoint();
     $endpoint->setTimeout($timeout);
     $context = $this->adapter->createContext($request, $endpoint);
     $this->assertEquals(array('http' => array('method' => $method, 'timeout' => $timeout, 'content' => file_get_contents(__FILE__), 'header' => 'Content-Type: multipart/form-data')), stream_context_get_options($context));
 }
Ejemplo n.º 4
0
 public function testSetAndGetFileUploadWithInvalidFile()
 {
     $this->setExpectedException('Solarium\\Exception\\RuntimeException');
     $this->request->setFileUpload('invalid-filename.dummy');
 }