public static function defaultHeaders() { $apiVersion = Rainforest::getApiVersion(); $version = Rainforest::VERSION; $headers = array_merge(["user_agent" => "Rainforest/" . $apiVersion . " Rainforest/" . $version], ["Content-Type" => "application/json", "CLIENT_TOKEN" => Rainforest::$apiKey]); try { $headers["x_rainforest_client_user_agent"] = json_encode(self::userAgent()); } catch (Exception $e) { $headers["x_rainforest_client_raw_user_agent"] = var_dump(self::userAgent()); $headers["error"] = "{$e}"; } return $headers; }
public function testShouldSetTheUserAgent() { $this->assertNotEmpty($this->builtHeaders['user_agent']); $this->assertNotEmpty(strpos($this->builtHeaders['user_agent'], Rainforest::getApiVersion())); $this->assertNotEmpty(strpos($this->builtHeaders['user_agent'], Rainforest::VERSION)); }