Skip to content

Commit

Permalink
Merge pull request #502 from clue-labs/bye-httpbin
Browse files Browse the repository at this point in the history
Update tests to remove defunct httpbin.org
  • Loading branch information
WyriHaximus committed Jul 8, 2023
2 parents 24dd698 + 7a5b57c commit c632197
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 75 deletions.
4 changes: 2 additions & 2 deletions examples/03-client-request-any.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

$promises = array(
$client->head('http://www.github.com/clue/http-react'),
$client->get('https://httpbin.org/'),
$client->get('https://httpbingo.org/'),
$client->get('https://google.com'),
$client->get('http://www.lueck.tv/psocksd'),
$client->get('http://www.httpbin.org/absolute-redirect/5')
$client->get('http://httpbingo.org/absolute-redirect/5')
);

React\Promise\any($promises)->then(function (ResponseInterface $response) use ($promises) {
Expand Down
2 changes: 1 addition & 1 deletion examples/04-client-post-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
);

$client->post(
'https://httpbin.org/post',
'https://httpbingo.org/post',
array(
'Content-Type' => 'application/json'
),
Expand Down
2 changes: 1 addition & 1 deletion examples/05-client-put-xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$child->name = 'Christian Lück';

$client->put(
'https://httpbin.org/put',
'https://httpbingo.org/put',
array(
'Content-Type' => 'text/xml'
),
Expand Down
4 changes: 2 additions & 2 deletions examples/22-client-stream-upload-from-stdin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

$in = new ReadableResourceStream(STDIN);

$url = isset($argv[1]) ? $argv[1] : 'https://httpbin.org/post';
$url = isset($argv[1]) ? $argv[1] : 'https://httpbingo.org/post';
echo 'Sending STDIN as POST to ' . $url . '…' . PHP_EOL;

$client->post($url, array(), $in)->then(function (ResponseInterface $response) {
$client->post($url, array('Content-Type' => 'text/plain'), $in)->then(function (ResponseInterface $response) {
echo 'Received' . PHP_EOL . Psr7\str($response);
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion examples/91-client-benchmark-download.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// a) simple download benchmark against public HTTP endpoint:
// $ php examples/91-client-benchmark-download.php http://httpbin.org/get
// $ php examples/91-client-benchmark-download.php http://httpbingo.org/get

// b) local 10 GB download benchmark against localhost address to avoid network overhead
//
Expand Down
66 changes: 0 additions & 66 deletions tests/Client/FunctionalIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,72 +152,6 @@ public function testSuccessfulResponseEmitsEnd()
\React\Async\await(\React\Promise\Timer\timeout($promise, self::TIMEOUT_REMOTE));
}

/** @group internet */
public function testPostDataReturnsData()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Not supported on HHVM');
}

// max_nesting_level was set to 100 for PHP Versions < 5.4 which resulted in failing test for legacy PHP
ini_set('xdebug.max_nesting_level', 256);

$client = new Client(new ClientConnectionManager(new Connector(), Loop::get()));

$data = str_repeat('.', 33000);
$request = $client->request(new Request('POST', 'https://' . (mt_rand(0, 1) === 0 ? 'eu.' : '') . 'httpbin.org/post', array('Content-Length' => strlen($data)), '', '1.0'));

$deferred = new Deferred();
$request->on('response', function (ResponseInterface $response, ReadableStreamInterface $body) use ($deferred) {
$deferred->resolve(Stream\buffer($body));
});

$request->on('error', 'printf');
$request->on('error', $this->expectCallableNever());

$request->end($data);

$buffer = \React\Async\await(\React\Promise\Timer\timeout($deferred->promise(), self::TIMEOUT_REMOTE));

$this->assertNotEquals('', $buffer);

$parsed = json_decode($buffer, true);
$this->assertTrue(is_array($parsed) && isset($parsed['data']));
$this->assertEquals(strlen($data), strlen($parsed['data']));
$this->assertEquals($data, $parsed['data']);
}

/** @group internet */
public function testPostJsonReturnsData()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Not supported on HHVM');
}

$client = new Client(new ClientConnectionManager(new Connector(), Loop::get()));

$data = json_encode(array('numbers' => range(1, 50)));
$request = $client->request(new Request('POST', 'https://httpbin.org/post', array('Content-Length' => strlen($data), 'Content-Type' => 'application/json'), '', '1.0'));

$deferred = new Deferred();
$request->on('response', function (ResponseInterface $response, ReadableStreamInterface $body) use ($deferred) {
$deferred->resolve(Stream\buffer($body));
});

$request->on('error', 'printf');
$request->on('error', $this->expectCallableNever());

$request->end($data);

$buffer = \React\Async\await(\React\Promise\Timer\timeout($deferred->promise(), self::TIMEOUT_REMOTE));

$this->assertNotEquals('', $buffer);

$parsed = json_decode($buffer, true);
$this->assertTrue(is_array($parsed) && isset($parsed['json']));
$this->assertEquals(json_decode($data, true), $parsed['json']);
}

/** @group internet */
public function testCancelPendingConnectionEmitsClose()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/FunctionalBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function testRequestWithAuthenticationSucceeds()

/**
* ```bash
* $ curl -vL "http://httpbin.org/redirect-to?url=http://user:pass@httpbin.org/basic-auth/user/pass"
* $ curl -vL "http://httpbingo.org/redirect-to?url=http://user:pass@httpbingo.org/basic-auth/user/pass"
* ```
*
* @doesNotPerformAssertions
Expand All @@ -244,7 +244,7 @@ public function testRedirectToPageWithAuthenticationSendsAuthenticationFromLocat

/**
* ```bash
* $ curl -vL "http://unknown:invalid@httpbin.org/redirect-to?url=http://user:pass@httpbin.org/basic-auth/user/pass"
* $ curl -vL "http://unknown:invalid@httpbingo.org/redirect-to?url=http://user:pass@httpbingo.org/basic-auth/user/pass"
* ```
*
* @doesNotPerformAssertions
Expand Down

0 comments on commit c632197

Please sign in to comment.