From c9930920821e00d35c69a9df2665c0c1d772c5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 15 Mar 2016 12:07:32 +0100 Subject: [PATCH] Revert "BufferedSink: Remove progress notifications" --- src/BufferedSink.php | 1 + tests/BufferedSinkTest.php | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/BufferedSink.php b/src/BufferedSink.php index 8fabc54..a6b35c0 100644 --- a/src/BufferedSink.php +++ b/src/BufferedSink.php @@ -31,6 +31,7 @@ public function handleErrorEvent($e) public function write($data) { $this->buffer .= $data; + $this->deferred->progress($data); } public function close() diff --git a/tests/BufferedSinkTest.php b/tests/BufferedSinkTest.php index adabbde..ee374d6 100644 --- a/tests/BufferedSinkTest.php +++ b/tests/BufferedSinkTest.php @@ -107,12 +107,21 @@ public function errorsShouldRejectPromise() } /** @test */ - public function writeShouldNotTriggerProgressOnPromise() + public function writeShouldTriggerProgressOnPromise() { $callback = $this->createCallableMock(); $callback - ->expects($this->never()) - ->method('__invoke'); + ->expects($this->at(0)) + ->method('__invoke') + ->with('foo'); + $callback + ->expects($this->at(1)) + ->method('__invoke') + ->with('bar'); + $callback + ->expects($this->at(2)) + ->method('__invoke') + ->with('baz'); $sink = new BufferedSink(); $sink @@ -120,6 +129,8 @@ public function writeShouldNotTriggerProgressOnPromise() ->then(null, null, $callback); $sink->write('foo'); + $sink->write('bar'); + $sink->end('baz'); } /** @test */