public function testCreateInvalidTransporter() { $this->swapConfig(['trucker::transporter.driver' => 'invalid']); Config::setApp($this->app); $this->setExpectedException('ReflectionException'); $this->setExpectedException('InvalidArgumentException'); $foo = TransporterFactory::build(); }
/** * Function to take a response string (as a string) and depending on * the type of string it is, parse it into an object. * * @return object */ public function parseResponseStringToObject() { $transporter = TransporterFactory::build(); return $transporter->parseResponseStringToObject($this->response); }
/** * Function to execute a raw request on the base URI with the given uri path * and params * * @param string $uri uri to hit (i.e. /users) * @param string $method Request method (GET, PUT, POST, PATCH, DELETE, etc.) * @param array $params PUT or POST parameters to send * @param array $getParams Querystring parameters to send * @param array $files PUT or POST files to send (key = name, value = path) * @param array $headers Optional headers to use * @return \Trucker\Responses\RawResponse */ public function rawRequest($uri, $method, $params = array(), $getParams = array(), $files = array(), $headers = array()) { $this->request = self::createRequest(Config::get('request.base_uri'), $uri, $method); $this->setPostParameters($params); $this->setGetParameters($getParams); $this->setFileParameters($files); $this->setHeaders($headers); //encode the request body /** @var \Trucker\Transporters\TransporterInterface $transporter */ $transporter = TransporterFactory::build(); $transporter->setRequestBody($this, $params); // Trucker\Response $response = $this->sendRequest(); //handle clean response with errors if (ResponseInterpreterFactory::build()->invalid($response)) { //get the errors and set them to our local collection $errors = (array) ErrorHandlerFactory::build()->parseErrors($response); return new RawResponse(false, $response, $errors); } //end if return new RawResponse(true, $response); }