コード例 #1
0
ファイル: StreamTest.php プロジェクト: smileytechguy/nLine
 /**
  * @covers React\Stream\Stream::handleData
  */
 public function testDataErrorShouldEmitErrorAndClose()
 {
     $stream = fopen('php://temp', 'r+');
     // add a filter which returns an error when encountering an 'a' when reading
     Filter\append($stream, function ($chunk) {
         if (strpos($chunk, 'a') !== false) {
             throw new \Exception('Invalid');
         }
         return $chunk;
     }, STREAM_FILTER_READ);
     $loop = $this->createLoopMock();
     $conn = new Stream($stream, $loop);
     $conn->on('data', $this->expectCallableNever());
     $conn->on('error', $this->expectCallableOnce());
     $conn->on('close', $this->expectCallableOnce());
     fwrite($stream, "foobar\n");
     rewind($stream);
     $conn->handleData($stream);
 }
コード例 #2
0
ファイル: FilterTest.php プロジェクト: clue/stream-filter
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidCallbackIsInvalidArgument()
 {
     $stream = $this->createStream();
     StreamFilter\append($stream, 'a-b-c');
 }