Exemple #1
0
<?php

/*
# Copyright 2015 NodeSocket, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
require_once __DIR__ . "/../Curl.php";
require_once __DIR__ . "/../Dogpatch.php";
use Dogpatch\Dogpatch;
$dogpatch = new Dogpatch(array("username" => "foo", "password" => 'bar', "timeout" => 10));
$dogpatch->get("https://api.stripe.com")->assertStatusCode(401)->assertHeadersExist(array("www-Authenticate"))->assertHeaders(array("Server" => "nginx", "Cache-Control" => "no-cache, no-store"))->assertBody(IS_VALID_JSON)->close();
Exemple #2
0
<?php

/*
# Copyright 2015 NodeSocket, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
require_once __DIR__ . "/../Curl.php";
require_once __DIR__ . "/../Dogpatch.php";
use Dogpatch\Dogpatch;
$dogpatch = new Dogpatch();
$dogpatch->get("https://freegeoip.net/json/8.8.8.8")->assertStatusCode(200)->assertHeadersExist(array("Content-Length"))->assertHeaders(array("Access-Control-Allow-Origin" => "*"))->assertBodyJsonFile(__DIR__ . "/json/freegeoip.net.json", PRINT_JSON)->close();
Exemple #3
0
<?php

/*
# Copyright 2015 NodeSocket, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
require_once __DIR__ . "/../Curl.php";
require_once __DIR__ . "/../Dogpatch.php";
use Dogpatch\Dogpatch;
$dogpatch = new Dogpatch();
$dogpatch->get("https://freegeoip.net/csv/8.8.8.8")->assertStatusCode(200)->assertHeaders(array("Access-Control-Allow-Origin" => "*"))->assertBody('"8.8.8.8","US","United States","","","","","38.0000","-97.0000","",""');
$dogpatch->get("https://www.google.com")->assertStatusCode(200)->assertHeadersExist(array("X-Frame-Options"))->assertHeaders(array("Server" => "gws", "Transfer-Encoding" => "chunked"))->assertBody("/<!doctype html>.*/", USE_REGEX);
$dogpatch->get("https://api.github.com")->assertStatusCode(200)->assertHeadersExist(array("X-GitHub-Request-Id", "ETag"))->assertHeaders(array("Server" => "GitHub.com"))->assertBody(IS_VALID_JSON)->assertTotalTimeLessThan(2)->close();
Exemple #4
0
# Copyright 2015 NodeSocket, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
require_once __DIR__ . "/../Curl.php";
require_once __DIR__ . "/../Dogpatch.php";
use Dogpatch\Dogpatch;
$expected = new stdClass();
$expected->ip = "8.8.8.8";
$expected->country_code = "US";
$expected->country_name = "United States";
$expected->region_code = "CA";
$expected->region_name = "California";
$expected->city = "Mountain View";
$expected->zip_code = "94035";
$expected->time_zone = "America/Los_Angeles";
$expected->latitude = 37.386;
$expected->longitude = -122.084;
$expected->metro_code = 807;
$dogpatch = new Dogpatch();
$dogpatch->get("https://freegeoip.net/json/8.8.8.8")->assertStatusCode(200)->assertHeadersExist(array("Date"))->assertHeaders(array("Access-Control-Allow-Origin" => "*"))->assertBodyPhp($expected, VAR_EXPORT)->close();
Exemple #5
0
<?php

/*
# Copyright 2015 NodeSocket, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
require_once __DIR__ . "/../Curl.php";
require_once __DIR__ . "/../Dogpatch.php";
use Dogpatch\Dogpatch;
$dogpatch = new Dogpatch(array("timeout" => 30));
$dogpatch->post("https://api.balancedpayments.com/api_keys")->assertStatusCode(201)->assertHeadersExist(array("X-Balanced-Host", "X-Balanced-Guru"))->assertHeaders(array("Content-Type" => "application/json"))->assertBody(IS_VALID_JSON)->close();