aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/stream/tests/FunctionalInternetTest.php
diff options
context:
space:
mode:
authormarvin-borner@live.com2018-04-16 21:09:05 +0200
committermarvin-borner@live.com2018-04-16 21:09:05 +0200
commitcf14306c2b3f82a81f8d56669a71633b4d4b5fce (patch)
tree86700651aa180026e89a66064b0364b1e4346f3f /assets/php/vendor/react/stream/tests/FunctionalInternetTest.php
parent619b01b3615458c4ed78bfaeabb6b1a47cc8ad8b (diff)
Main merge to user management system - files are now at /main/public/
Diffstat (limited to 'assets/php/vendor/react/stream/tests/FunctionalInternetTest.php')
-rwxr-xr-xassets/php/vendor/react/stream/tests/FunctionalInternetTest.php122
1 files changed, 0 insertions, 122 deletions
diff --git a/assets/php/vendor/react/stream/tests/FunctionalInternetTest.php b/assets/php/vendor/react/stream/tests/FunctionalInternetTest.php
deleted file mode 100755
index 4d31e8e..0000000
--- a/assets/php/vendor/react/stream/tests/FunctionalInternetTest.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-namespace React\Tests\Stream;
-
-use React\EventLoop\Factory;
-use React\EventLoop\LoopInterface;
-use React\Stream\DuplexResourceStream;
-use React\Stream\WritableResourceStream;
-
-/**
- * @group internet
- */
-class FunctionalInternetTest extends TestCase
-{
- public function testUploadKilobytePlain()
- {
- $size = 1000;
- $stream = stream_socket_client('tcp://httpbin.org:80');
-
- $loop = Factory::create();
- $stream = new DuplexResourceStream($stream, $loop);
-
- $buffer = '';
- $stream->on('data', function ($chunk) use (&$buffer) {
- $buffer .= $chunk;
- });
-
- $stream->on('error', $this->expectCallableNever());
-
- $stream->write("POST /post HTTP/1.0\r\nHost: httpbin.org\r\nContent-Length: $size\r\n\r\n" . str_repeat('.', $size));
-
- $this->awaitStreamClose($stream, $loop);
-
- $this->assertNotEquals('', $buffer);
- }
-
- public function testUploadBiggerBlockPlain()
- {
- $size = 50 * 1000;
- $stream = stream_socket_client('tcp://httpbin.org:80');
-
- $loop = Factory::create();
- $stream = new DuplexResourceStream($stream, $loop);
-
- $buffer = '';
- $stream->on('data', function ($chunk) use (&$buffer) {
- $buffer .= $chunk;
- });
-
- $stream->on('error', $this->expectCallableNever());
-
- $stream->write("POST /post HTTP/1.0\r\nHost: httpbin.org\r\nContent-Length: $size\r\n\r\n" . str_repeat('.', $size));
-
- $this->awaitStreamClose($stream, $loop);
-
- $this->assertNotEquals('', $buffer);
- }
-
- public function testUploadKilobyteSecure()
- {
- $size = 1000;
- $stream = stream_socket_client('tls://httpbin.org:443');
-
- $loop = Factory::create();
- $stream = new DuplexResourceStream($stream, $loop);
-
- $buffer = '';
- $stream->on('data', function ($chunk) use (&$buffer) {
- $buffer .= $chunk;
- });
-
- $stream->on('error', $this->expectCallableNever());
-
- $stream->write("POST /post HTTP/1.0\r\nHost: httpbin.org\r\nContent-Length: $size\r\n\r\n" . str_repeat('.', $size));
-
- $this->awaitStreamClose($stream, $loop);
-
- $this->assertNotEquals('', $buffer);
- }
-
- public function testUploadBiggerBlockSecureRequiresSmallerChunkSize()
- {
- $size = 50 * 1000;
- $stream = stream_socket_client('tls://httpbin.org:443');
-
- $loop = Factory::create();
- $stream = new DuplexResourceStream(
- $stream,
- $loop,
- null,
- new WritableResourceStream($stream, $loop, null, 8192)
- );
-
- $buffer = '';
- $stream->on('data', function ($chunk) use (&$buffer) {
- $buffer .= $chunk;
- });
-
- $stream->on('error', $this->expectCallableNever());
-
- $stream->write("POST /post HTTP/1.0\r\nHost: httpbin.org\r\nContent-Length: $size\r\n\r\n" . str_repeat('.', $size));
-
- $this->awaitStreamClose($stream, $loop);
-
- $this->assertNotEquals('', $buffer);
- }
-
- private function awaitStreamClose(DuplexResourceStream $stream, LoopInterface $loop, $timeout = 10.0)
- {
- $stream->on('close', function () use ($loop) {
- $loop->stop();
- });
-
- $that = $this;
- $loop->addTimer($timeout, function () use ($loop, $that) {
- $loop->stop();
- $that->fail('Timed out while waiting for stream to close');
- });
-
- $loop->run();
- }
-}