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

Commit 54f3a9a

Browse files
committed
#223 #224 avoiding output in the CLI, minor CS fixes (alignment)
1 parent dcdd787 commit 54f3a9a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

test/Response/SapiStreamEmitterTest.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ public function testEmitBody($seekable, $contents, $maxBufferLength, $expectedRe
8686
return ! isset($contents[$position]);
8787
});
8888

89-
$stream->read(Argument::type('integer'))->will(function ($args) use (&$contents, &$position) {
90-
$data = substr($contents, $position, $args[0]);
91-
$position += strlen($data);
92-
return $data;
89+
$stream->read(Argument::type('integer'))->will(function ($args) use (& $contents, & $position) {
90+
$data = substr($contents, $position, $args[0]);
91+
$position += strlen($data);
92+
93+
return $data;
9394
});
9495

9596
$response = (new Response())
@@ -131,20 +132,16 @@ public function testEmitMemoryUsage($seekable, $maxBufferLength, $sizeBlocks, $m
131132
$peakBufferLength = 0;
132133
$peakMemoryUsage = 0;
133134

135+
$position = 0;
136+
134137
if ($rangeBlocks) {
135-
$first = $maxBufferLength * $rangeBlocks[0];
136-
$last = $maxBufferLength * $rangeBlocks[1];
138+
$first = $maxBufferLength * $rangeBlocks[0];
139+
$last = $maxBufferLength * $rangeBlocks[1];
137140
$position = $first;
138-
} else {
139-
$position = 0;
140141
}
141142

142-
$closureTrackMemoryUsage = function () use (&$peakMemoryUsage) {
143-
$memoryUsage = memory_get_usage();
144-
145-
if ($memoryUsage > $peakMemoryUsage) {
146-
$peakMemoryUsage = $memoryUsage;
147-
}
143+
$closureTrackMemoryUsage = function () use (& $peakMemoryUsage) {
144+
$peakMemoryUsage = max($peakMemoryUsage, memory_get_usage());
148145
};
149146

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

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

203-
ob_end_flush();
200+
ob_end_clean();
204201

205202
gc_collect_cycles();
206203

0 commit comments

Comments
 (0)