-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to get an understanding on what happens within the loop I added an ad…
…ditional test
- Loading branch information
1 parent
e50115f
commit 42c969c
Showing
4 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace VaasTesting; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use React\EventLoop\Loop; | ||
use React\Http\Browser; | ||
use React\Stream\ReadableResourceStream; | ||
use React\Stream\ReadableStreamInterface; | ||
use React\Stream\ThroughStream; | ||
use React\Stream\Util; | ||
use React\Stream\WritableResourceStream; | ||
|
||
use function React\Async\await; | ||
use function React\Promise\Stream\buffer; | ||
|
||
final class StreamsInLoopTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
public function testLoopUnexpectedConsumesStreamWithBrowser() { | ||
$browser1 = new Browser(); | ||
$browser2 = new Browser(); | ||
|
||
$response1 = await($browser1->requestStreaming("GET", "https://secure.eicar.org/eicar.com.txt")); | ||
$body1 = $response1->getBody(); | ||
$this->assertEquals(true, $body1->isReadable()); | ||
|
||
$response2 = await($browser2->requestStreaming("GET", "https://secure.eicar.org/eicar.com.txt")); | ||
$this->assertEquals(true, $body1->isReadable()); | ||
$body2 = $response2->getBody(); | ||
$this->assertEquals(true, $body2->isReadable()); | ||
|
||
assert($body2 instanceof ReadableStreamInterface); | ||
$string2 = await(buffer($body2)); | ||
} | ||
|
||
static function random_strings($length_of_string) { | ||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
$characters_length = strlen($characters); | ||
$random_string = ''; | ||
|
||
// Generate random characters until the string reaches desired length | ||
for ($i = 0; $i < $length_of_string; $i++) { | ||
$random_index = random_int(0, $characters_length - 1); | ||
$random_string .= $characters[$random_index]; | ||
} | ||
|
||
return $random_string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters