Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
#223 #224 avoiding output in the CLI, minor CS fixes (alignment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jan 17, 2017
1 parent dcdd787 commit 54f3a9a
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions test/Response/SapiStreamEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ public function testEmitBody($seekable, $contents, $maxBufferLength, $expectedRe
return ! isset($contents[$position]);
});

$stream->read(Argument::type('integer'))->will(function ($args) use (&$contents, &$position) {
$data = substr($contents, $position, $args[0]);
$position += strlen($data);
return $data;
$stream->read(Argument::type('integer'))->will(function ($args) use (& $contents, & $position) {
$data = substr($contents, $position, $args[0]);
$position += strlen($data);

return $data;
});

$response = (new Response())
Expand Down Expand Up @@ -131,20 +132,16 @@ public function testEmitMemoryUsage($seekable, $maxBufferLength, $sizeBlocks, $m
$peakBufferLength = 0;
$peakMemoryUsage = 0;

$position = 0;

if ($rangeBlocks) {
$first = $maxBufferLength * $rangeBlocks[0];
$last = $maxBufferLength * $rangeBlocks[1];
$first = $maxBufferLength * $rangeBlocks[0];
$last = $maxBufferLength * $rangeBlocks[1];
$position = $first;
} else {
$position = 0;
}

$closureTrackMemoryUsage = function () use (&$peakMemoryUsage) {
$memoryUsage = memory_get_usage();

if ($memoryUsage > $peakMemoryUsage) {
$peakMemoryUsage = $memoryUsage;
}
$closureTrackMemoryUsage = function () use (& $peakMemoryUsage) {
$peakMemoryUsage = max($peakMemoryUsage, memory_get_usage());
};

$closureFullContents = function () use (&$sizeBytes) {
Expand Down Expand Up @@ -200,7 +197,7 @@ public function testEmitMemoryUsage($seekable, $maxBufferLength, $sizeBlocks, $m

$this->emitter->emit($response, $maxBufferLength);

ob_end_flush();
ob_end_clean();

gc_collect_cycles();

Expand Down

0 comments on commit 54f3a9a

Please sign in to comment.